Repository navigation
Analyze Java with a build in CodeQL - #2337
Merged
akurtakov merged 1 commit intoDec 3, 2026
Merged
Conversation
Buildless analysis can't resolve the p2 dependencies of the Tycho build. Calls into Eclipse, LSP4E or JUnit then have unknown types, and CodeQL reports variables passed to them as never read and lambda parameters as unused. Compile the sources so CodeQL sees the real types. Assisted-by: Anthropic Claude Code (claude-opus-5-5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodeQL analyses Java with
build-mode: none, which can't resolve the p2 dependencies of the Tycho build. Calls into Eclipse, LSP4E or JUnit then have unknown types, which causes false positives:java/local-variable-is-never-readfor variables only passed to such calls (e.g.indent4inassertNotEquals(indent4, ...));java/unused-parameterfor lambda parameters, including the unnamed_, because CodeQL can't tell which interface the lambda implements.This switches Java to
build-mode: manualand compiles the sources with./mvnw compilebetween CodeQL's init and analyze steps.Tested with a manual run on my fork: CodeQL scanned 202 of 202 Java files. Compared with the open alerts on master:
local-variable-is-never-read: 18 → 0unused-parameter: 48 → 9; the remaining ones are named, really unused parametersunsafe-get-resource: 2 → 13; with the real types CodeQL now finds moregetClass().getResource()usesThe other Java results are about the same.