Skip to content

fix: address CodeQL quality alerts - #480

Merged
tony19 merged 3 commits into
mainfrom
fix/codeql-quality-alerts
Sep 29, 2026
Merged

tony19 merged 3 commits into
mainfrom
fix/codeql-quality-alerts

Conversation

@tony19

@tony19 tony19 commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Follow-up to #479. This takes the open CodeQL alerts from 650 to 67, measured by a local CodeQL 2.27.1 run of the same security-and-quality suite that codeql.yml uses. It also fixes main's red Static Analysis.

Review commit by commit:

  1. style: add missing @Override annotations adds 553 @Override lines and nothing else. Every one compiles at --release 8, which confirms each method really does override.
  2. ci: catalogue Kotlin packages in the architecture-docs gate: Static Analysis has failed on main since refactor: convert the Android-specific layer to Kotlin聽#388, because check-architecture-docs.sh only scanned src/main/java and reported classic/android and core/android as stale. It now scans both source roots, for the package catalogue and for both dependency rules. components.md and the architecture-sync skill now mention src/main/kotlin.
  3. fix: address CodeQL quality alerts

Bugs fixed

  • SiftingAppenderBase.start() threw an NPE instead of reporting "Missing discriminator" when none was configured. New SiftingAppenderBaseTest.
  • AbstractSocketAppender threw an NPE once the host resolved if reconnectionDelay was null. Null now counts as zero, which is what the resolution retry loop already did.
  • Compressor leaked the FileOutputStream when the GZIPOutputStream constructor threw (the constructor writes the gzip header).
  • ElementPath overrode equals() without hashCode(). The new hashCode() folds case the same way equalsIgnoreCase does. New ElementPathTest.
  • Logger.level is now volatile: getLevel() read it without the lock that setLevel() holds.
  • ScanException overrode Throwable's synchronized getCause(). It now passes the cause to Throwable instead.
  • ConfigurationWatchList decoded file URLs with the platform charset through the deprecated URLDecoder.decode(String). It now decodes them as UTF-8, which is the encoding URL escapes use.

Cleanups

  • Always-true instanceof and count checks
  • Redundant toString() calls
  • A local variable that shadowed a field
  • An inner class that is now static
  • Missing spaces in two status messages
  • Stale Javadoc @param names
  • "No context given" printed ContextAwareImpl's default toString(); it now prints the origin
  • Unused parameters of private and package-private methods only (no public API changes)

Remaining 67 alerts

These can't be fixed without breaking the public API or the Android / Java 8 floor, so they need dismissing on the Security tab after merge:

Rule # Dismiss as Why
unused-parameter 24 Won't fix Public or overridable signatures
confusing-method-signature 17 Won't fix slf4j Logger overloads
uncaught-number-format-exception 6 False positive Callers catch it, or a digits-only regex feeds the parse
deprecated-call 5 Won't fix Locale.of and URI.toURL replacements aren't available on Android / Java 8 or behave differently
confusing-method-name 4 Won't fix Public setSMTPHost / setSmtpHost config names
unsafe-deserialization 3 False positive Class allowlist (#479)
internal-representation-exposure 3 Won't fix Callers mutate these collections on purpose
missing-clone-method 2 Won't fix clone() is inherited
unsafe-cert-trust 1 False positive Hostname verification is on by default (#479)
class-name-matches-super-class 1 Won't fix Logger implements org.slf4j.Logger
ignored-error-status-of-call 1 Won't fix neverBlock drops events when the queue is full, by design

Testing

  • Main sources (Java + Kotlin) compile at Java 8.
  • Ran the unit suite in a scratch Maven build on main and on this branch. Both give 721 passing, with no pass/fail differences. Robolectric tests can't load in that sandbox (no Google Maven access), so CI is their real check.
  • The two new tests fail on main and pass here.
  • ./scripts/check-architecture-docs.sh passes; on main it fails.

Deferred work considered: none of the open issues (#135, #223, #344, #352, #366, #371) touch the changed code.

馃 Generated with Claude Code

https://claude.ai/code/session_01EZEDsWHuCKX7Cdwm6KvjpF


Generated by Claude Code

Adds @OverRide to the 553 methods that CodeQL's
java/missing-override-annotation flags. No behavior change; compiled at
--release 8 to confirm each one really overrides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZEDsWHuCKX7Cdwm6KvjpF
#388 moved the Android layer to src/main/kotlin, so the gate, which only
scanned src/main/java, reported classic/android and core/android as
stale and turned Static Analysis red on main. Scan both source roots
for the package catalogue and both dependency rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZEDsWHuCKX7Cdwm6KvjpF
Bugs:
- SiftingAppenderBase.start() threw NullPointerException instead of
  reporting "Missing discriminator" when none was configured.
- AbstractSocketAppender threw NullPointerException once the host
  resolved if reconnectionDelay was set to null; treat null as zero,
  as the resolution retry loop already did.
- Compressor leaked the FileOutputStream when the GZIPOutputStream
  constructor threw (it writes the gzip header).
- ElementPath overrode equals() without hashCode(); add one consistent
  with its case-insensitive comparison.
- Logger.getLevel() read the level without the lock setLevel() holds;
  make the field volatile.
- ScanException overrode Throwable's synchronized getCause() with an
  unsynchronized one; pass the cause to Throwable instead.
- ConfigurationWatchList decoded file URLs with the platform charset
  (deprecated URLDecoder.decode(String)); URL escapes are UTF-8.

Cleanups: always-true instanceof and count checks, redundant
toString() calls, a shadowed field, a non-static inner class, missing
spaces in two status messages, stale Javadoc @PARAM names, the "No
context given" message printing ContextAwareImpl's default toString(),
and unused parameters of private and package-private methods.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZEDsWHuCKX7Cdwm6KvjpF
@tony19 tony19 added the run-ci-on-drafts label Sep 29, 2026 — with Claude
@tony19
tony19 marked this pull request as ready for review September 29, 2026 06:11
@tony19 tony19 removed the run-ci-on-drafts label Sep 29, 2026 — with Claude
@tony19
tony19 merged commit 70666f0 into main Sep 29, 2026
17 checks passed
@tony19
tony19 deleted the fix/codeql-quality-alerts branch September 29, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants