Skip to content

SONARJAVA-6082 S8471 Minimize the number of bound ScopedValues for performance#5498

Open
aurelien-coet-sonarsource wants to merge 4 commits intomasterfrom
ac/SONARJAVA-6082
Open

SONARJAVA-6082 S8471 Minimize the number of bound ScopedValues for performance#5498
aurelien-coet-sonarsource wants to merge 4 commits intomasterfrom
ac/SONARJAVA-6082

Conversation

@aurelien-coet-sonarsource
Copy link
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Contributor

hashicorp-vault-sonar-prod bot commented Feb 27, 2026

SONARJAVA-6082

Copy link
Contributor

@rombirli rombirli left a comment

Choose a reason for hiding this comment

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

Should we also check the case carrier are assigned to variables? for example

var c1 = ScopedValue.where(...)
var c2 = c1.where(...)
...

@sonarqube-next
Copy link

@rombirli
Copy link
Contributor

rombirli commented Mar 3, 2026

We still aren't detecting cases like the one below. As Asya suggested, there may be a more robust way to handle this, specifically by identifying which Scoped Values are consistently bound together. Let's hold off on including this in the current release and refine the proposal for a later update.

void main() {
  ScopedValue.Carrier c1 = ScopedValue.where(ScopedValue.newInstance(), "John");
  ScopedValue.Carrier c2 = c1.where(ScopedValue.newInstance(), "John");
  ScopedValue.Carrier c3 = c2.where(ScopedValue.newInstance(), "John"); // Noncompliant
  ScopedValue.Carrier c4 = c3.where(ScopedValue.newInstance(), "John"); // Noncompliant
}

@rombirli rombirli added the stale label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants