fix: qualify Java record method names and analyze compact constructors#459
Merged
askpt merged 2 commits intoJul 17, 2026
Merged
Conversation
…constructors
- Add `record_declaration` to parent-type check in `getMethodName()` so
methods declared inside a Java record are displayed as `RecordName.methodName`
instead of the bare `methodName`.
- Add `compact_constructor_declaration` to `METHOD_DECLARATION_TYPES` so
compact record constructors (e.g. `record Range(int s, int e) { Range { … } }`)
are included in complexity analysis rather than silently skipped.
- Add 2 unit tests covering both gaps (177 tests passing, 0 failing).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6 tasks
…0714-07b945d2455d0b26
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #459 +/- ##
=======================================
Coverage 81.53% 81.54%
=======================================
Files 13 13
Lines 4274 4276 +2
Branches 440 441 +1
=======================================
+ Hits 3485 3487 +2
Misses 787 787
Partials 2 2 ☔ 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 closes two functional gaps in the Java cognitive-complexity analyzer related to modern Java record types, ensuring record members are named consistently with other type declarations and that compact record constructors are included in analysis.
Changes:
- Qualify method names declared inside
recordbodies asRecordName.method(consistent with classes/interfaces/enums). - Include
compact_constructor_declarationnodes in the set of Java “function-like” declarations to analyze. - Add unit tests covering record method name qualification and compact constructor complexity analysis.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/metricsAnalyzer/languages/javaAnalyzer.ts |
Adds support for record name qualification and compact constructor detection in the Java analyzer. |
src/unit/unit.test.ts |
Adds regression tests ensuring record methods are qualified and compact record constructors are analyzed. |
askpt
deleted the
repo-assist/fix-java-record-method-name-20260714-07b945d2455d0b26
branch
July 17, 2026 09:55
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 is an automated pull request from Repo Assist.
Summary
Fixes two gaps in the Java analyzer for modern Java record types (Java 16+):
Method name qualification: Methods declared inside a
recordwere displayed as bare names (e.g.sum) instead of the qualifiedRecordName.sum. This is now consistent with class, interface, and enum methods.Compact record constructors silently skipped: The compact constructor form —
record Range(int s, int e) { Range { ... } }— uses thecompact_constructor_declarationnode type, which was not inMETHOD_DECLARATION_TYPES. These constructors could contain complex validation logic but were never analyzed.Root Cause
getMethodName()checked forclass_declaration | interface_declaration | enum_declarationas parent types but omittedrecord_declaration.METHOD_DECLARATION_TYPESincludedmethod_declarationandconstructor_declarationbut notcompact_constructor_declaration.Changes
javaAnalyzer.ts: addrecord_declarationto the parent-type check ingetMethodName()javaAnalyzer.ts: addcompact_constructor_declarationtoMETHOD_DECLARATION_TYPESunit.test.ts: 2 new tests — record method qualification, compact constructor analysisTest Status
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 workflows to your repo
To install this agentic workflow, run