Skip to content

fix: qualify Java record method names and analyze compact constructors#459

Merged
askpt merged 2 commits into
mainfrom
repo-assist/fix-java-record-method-name-20260714-07b945d2455d0b26
Jul 17, 2026
Merged

fix: qualify Java record method names and analyze compact constructors#459
askpt merged 2 commits into
mainfrom
repo-assist/fix-java-record-method-name-20260714-07b945d2455d0b26

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

Fixes two gaps in the Java analyzer for modern Java record types (Java 16+):

  1. Method name qualification: Methods declared inside a record were displayed as bare names (e.g. sum) instead of the qualified RecordName.sum. This is now consistent with class, interface, and enum methods.

  2. Compact record constructors silently skipped: The compact constructor form — record Range(int s, int e) { Range { ... } } — uses the compact_constructor_declaration node type, which was not in METHOD_DECLARATION_TYPES. These constructors could contain complex validation logic but were never analyzed.

Root Cause

getMethodName() checked for class_declaration | interface_declaration | enum_declaration as parent types but omitted record_declaration.

METHOD_DECLARATION_TYPES included method_declaration and constructor_declaration but not compact_constructor_declaration.

Changes

  • javaAnalyzer.ts: add record_declaration to the parent-type check in getMethodName()
  • javaAnalyzer.ts: add compact_constructor_declaration to METHOD_DECLARATION_TYPES
  • unit.test.ts: 2 new tests — record method qualification, compact constructor analysis

Test Status

npm run compile  ✅  (0 errors)
npm run lint     ✅  (0 warnings)
npm run test:unit  ✅  177 passing, 0 failing (was 175)

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1c6668b751c51af8571f01204ceffb19362e0f66

…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>
@askpt askpt changed the title [repo-assist] fix: qualify Java record method names and analyze compact constructors fix: qualify Java record method names and analyze compact constructors Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.54%. Comparing base (e7eea3b) to head (c098842).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@askpt
askpt marked this pull request as ready for review July 17, 2026 09:51
@askpt
askpt self-requested a review as a code owner July 17, 2026 09:51
Copilot AI review requested due to automatic review settings July 17, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 record bodies as RecordName.method (consistent with classes/interfaces/enums).
  • Include compact_constructor_declaration nodes 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
askpt merged commit a91c6b9 into main Jul 17, 2026
10 checks passed
@askpt
askpt deleted the repo-assist/fix-java-record-method-name-20260714-07b945d2455d0b26 branch July 17, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants