test: add Java switch tests and mark unreachable getMethodName fallback with c8 ignore#478
Merged
askpt merged 2 commits intoJul 26, 2026
Conversation
…h c8 ignore - Add two new tests for Java switch analysis: * Traditional switch statement (adds +1 complexity) * Modern Java 14+ switch expression (also adds +1 via switch_expression node) - Annotate the unreachable getMethodName fallback (return methodName without class prefix) with /* c8 ignore start/stop */ — valid Java always has methods inside a class, interface, enum, or record declaration Tests: 200 passing (was 198) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #478 +/- ##
==========================================
+ Coverage 81.40% 81.43% +0.02%
==========================================
Files 13 13
Lines 4345 4346 +1
Branches 440 440
==========================================
+ Hits 3537 3539 +2
+ Misses 807 806 -1
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Java cognitive complexity analyzer test coverage around switch constructs and adjusts coverage annotations in the Java analyzer’s method-name resolution fallback.
Changes:
- Added unit tests for Java
switchparsing/complexity, including a Java 14+ arrow-case switch expression. - Added
c8coverage-ignore annotations around thegetMethodNamefallback return in the Java analyzer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/unit/unit.test.ts |
Adds Java switch tests (traditional + Java 14+ switch expression) to the unit test suite. |
src/metricsAnalyzer/languages/javaAnalyzer.ts |
Adds c8 ignore start/stop around the getMethodName fallback return path. |
…gnore annotation Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
askpt
enabled auto-merge (squash)
July 26, 2026 13:13
askpt
approved these changes
Jul 26, 2026
askpt
deleted the
repo-assist/improve-java-coverage-20260726-06cc6a5651461acf
branch
July 26, 2026 13:13
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.
🤖 This pull request was created by Repo Assist, an automated AI assistant.
Summary
Two improvements to the Java analyzer:
switchanalysis — covers both the traditionalswitchstatement and the modern Java 14+ arrow-case switch expression.c8 ignoreannotation on thegetMethodNamefallback path — marks the unreachablereturn methodName(no enclosing class found) so coverage reports accurately reflect only executable code paths.Changes
src/metricsAnalyzer/languages/javaAnalyzer.tsAnnotated the
return methodNamefallback ingetMethodNamewith/* c8 ignore start/stop */. Valid Java always places methods inside aclass_declaration,interface_declaration,enum_declaration, orrecord_declaration. The fallback is a defensive guard — impossible to reach with syntactically valid Java source.src/unit/unit.test.tsAdded two new tests to the
Java Analyzer: Enum methodssuite (alongside existing tests, they're logically close to other complex-method-name tests):switch (n) { case 1: ... }→switch_expressionnode in tree-sitter-java → complexity +1, reason"switch statement".switch (day) { case "X" -> 6; }→ sameswitch_expressionnode → complexity +1, confirming both Java switch forms are correctly analyzed.Test Status
Coverage
javaAnalyzer.ts: 99.53% lines, 96% branches (remaining uncovered branches are/* c8 ignore */-annotated defensive dead paths).Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comSee Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run