#39 Harden Java parser coverage#81
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Java method discovery so cognitive complexity analysis includes constructors and methods inside local/anonymous classes, while improving diagnostic formatting for positionless javac errors.
Changes:
- Splits parsed method identity from report display names.
- Adds constructor, compact record constructor, local class, and anonymous class discovery.
- Adds tests for new parser coverage and JUnit/threshold report behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
core/src/main/java/media/barney/cognitive/core/ParsedMethod.java |
Separates declaration identity from display name. |
core/src/main/java/media/barney/cognitive/core/JavaMethodParser.java |
Expands method discovery and hardens source/diagnostic position handling. |
core/src/main/java/media/barney/cognitive/core/CognitiveComplexityAnalyzer.java |
Computes complexities by parsed method id and reports display names. |
core/src/test/java/media/barney/cognitive/core/JavaMethodParserTest.java |
Adds parser coverage for constructors, nested methods, packages, and NOPOS handling. |
core/src/test/java/media/barney/cognitive/core/CliApplicationTest.java |
Verifies newly discovered methods flow into thresholds and JUnit reports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #39
Summary
Diagnostic.NOPOSsource positions and format positionless diagnostics with?Review Focus
JavaMethodParsercontext stacks for class identity vs report display namesValidation
mvn -B -ntp -P!quality-gates-all -pl core '-Dtest=JavaMethodParserTest,CliApplicationTest' testmvn -B -ntp -P!quality-gates-all verifymvn -B -ntp verify '-Dcentral.skipPublishing=true'mvn -B -ntp '-P!quality-gates-all,quality-gate-cognitive' -DskipTests verifyincoremvn -B -ntp '-P!quality-gates-all,quality-gate-crap' -DskipTests verifyincoremvn -B -ntp '-P!quality-gates-all,quality-gate-spotbugs' -DskipTests verifyincoregradle-plugin/.\gradlew.bat test validatePlugins publishToMavenLocalResidual Risk