Skip to content

Analyze Java with a build in CodeQL - #2337

Merged
akurtakov merged 1 commit into
eclipse-wildwebdeveloper:masterfrom
akurtakov:codeql-java-build
Dec 3, 2026
Merged

akurtakov merged 1 commit into
eclipse-wildwebdeveloper:masterfrom
akurtakov:codeql-java-build

Conversation

@akurtakov

Copy link
Copy Markdown
Contributor

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-read for variables only passed to such calls (e.g. indent4 in assertNotEquals(indent4, ...));
  • java/unused-parameter for lambda parameters, including the unnamed _, because CodeQL can't tell which interface the lambda implements.

This switches Java to build-mode: manual and compiles the sources with ./mvnw compile between 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 → 0
  • unused-parameter: 48 → 9; the remaining ones are named, really unused parameters
  • unsafe-get-resource: 2 → 13; with the real types CodeQL now finds more getClass().getResource() uses

The other Java results are about the same.

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)
@akurtakov
akurtakov merged commit 10c06b9 into eclipse-wildwebdeveloper:master Dec 3, 2026
6 checks passed
@akurtakov
akurtakov deleted the codeql-java-build branch December 3, 2026 05:52
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.

1 participant