Skip to content

#39 Harden Java parser coverage#81

Merged
fabian-barney merged 3 commits into
mainfrom
codex/39-parser-hardening
May 31, 2026
Merged

#39 Harden Java parser coverage#81
fabian-barney merged 3 commits into
mainfrom
codex/39-parser-hardening

Conversation

@fabian-barney

Copy link
Copy Markdown
Owner

Closes #39

Summary

  • include constructors, compact record constructors, local class methods, and anonymous class methods in parser discovery
  • keep normal method display names unchanged while using contextual display names for local and anonymous methods
  • guard javac Diagnostic.NOPOS source positions and format positionless diagnostics with ?

Review Focus

  • JavaMethodParser context stacks for class identity vs report display names
  • recursion identity staying based on declaration names while reports use display names
  • NOPOS handling and the decision to skip methods that cannot be represented with line ranges

Validation

  • mvn -B -ntp -P!quality-gates-all -pl core '-Dtest=JavaMethodParserTest,CliApplicationTest' test
  • mvn -B -ntp -P!quality-gates-all verify
  • mvn -B -ntp verify '-Dcentral.skipPublishing=true'
  • mvn -B -ntp '-P!quality-gates-all,quality-gate-cognitive' -DskipTests verify in core
  • mvn -B -ntp '-P!quality-gates-all,quality-gate-crap' -DskipTests verify in core
  • mvn -B -ntp '-P!quality-gates-all,quality-gate-spotbugs' -DskipTests verify in core
  • gradle-plugin/.\gradlew.bat test validatePlugins publishToMavenLocal

Residual Risk

  • Newly discovered constructor/local/anonymous methods can create new threshold failures by design.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread core/src/test/java/media/barney/cognitive/core/JavaMethodParserTest.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@fabian-barney fabian-barney merged commit 99c4581 into main May 31, 2026
21 checks passed
@fabian-barney fabian-barney deleted the codex/39-parser-hardening branch May 31, 2026 12:56
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.

Harden Java parser coverage for constructors, anonymous classes, diagnostics, and package parsing

2 participants