Skip to content

PLUGINAPI-200 Add explicit CPD unit boundaries to NewCpdTokens#304

Draft
henryju wants to merge 1 commit into
masterfrom
jh/explicit-cpd-units
Draft

PLUGINAPI-200 Add explicit CPD unit boundaries to NewCpdTokens#304
henryju wants to merge 1 commit into
masterfrom
jh/explicit-cpd-units

Conversation

@henryju

@henryju henryju commented Jul 17, 2026

Copy link
Copy Markdown
Member

Lets a sensor group tokens into CPD units via explicit withExplicitUnitBoundaries()/endUnit() calls instead of the default per-physical-line grouping, so languages using statement-shaped units (e.g. Java) don't need to bypass NewCpdTokens entirely.

Lets a sensor group tokens into CPD units via explicit withExplicitUnitBoundaries()/endUnit() calls instead of the default per-physical-line grouping, so languages using statement-shaped units (e.g. Java) don't need to bypass NewCpdTokens entirely.
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Add explicit CPD unit boundaries to NewCpdTokens PLUGINAPI-200 Add explicit CPD unit boundaries to NewCpdTokens Jul 17, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 17, 2026

Copy link
Copy Markdown

PLUGINAPI-200

* Calling it more than once is allowed and has no additional effect.
* @since 13.9
*/
NewCpdTokens withExplicitUnitBoundaries();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Quality: New abstract methods on public interface break implementers

Adding withExplicitUnitBoundaries() and endUnit() as abstract methods to the published NewCpdTokens interface is a source/binary-incompatible change for any code that implements the interface (test doubles, alternative scanner impls). Consider providing default implementations (e.g. endUnit() throwing UnsupportedOperationException and withExplicitUnitBoundaries() returning this) so existing implementers keep compiling, consistent with how additive interface methods are typically handled in a stable plugin API.

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Introduces explicit CPD unit boundaries to the NewCpdTokens interface to support statement-shaped token grouping. Adding these as abstract methods creates a binary compatibility break for existing interface implementers; consider providing default implementations instead.

💡 Quality: New abstract methods on public interface break implementers

📄 plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:89 📄 plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:96

Adding withExplicitUnitBoundaries() and endUnit() as abstract methods to the published NewCpdTokens interface is a source/binary-incompatible change for any code that implements the interface (test doubles, alternative scanner impls). Consider providing default implementations (e.g. endUnit() throwing UnsupportedOperationException and withExplicitUnitBoundaries() returning this) so existing implementers keep compiling, consistent with how additive interface methods are typically handled in a stable plugin API.

🤖 Prompt for agents
Code Review: Introduces explicit CPD unit boundaries to the NewCpdTokens interface to support statement-shaped token grouping. Adding these as abstract methods creates a binary compatibility break for existing interface implementers; consider providing default implementations instead.

1. 💡 Quality: New abstract methods on public interface break implementers
   Files: plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:89, plugin-api/src/main/java/org/sonar/api/batch/sensor/cpd/NewCpdTokens.java:96

   Adding `withExplicitUnitBoundaries()` and `endUnit()` as abstract methods to the published `NewCpdTokens` interface is a source/binary-incompatible change for any code that implements the interface (test doubles, alternative scanner impls). Consider providing `default` implementations (e.g. `endUnit()` throwing UnsupportedOperationException and `withExplicitUnitBoundaries()` returning `this`) so existing implementers keep compiling, consistent with how additive interface methods are typically handled in a stable plugin API.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown

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.

1 participant