Skip to content

SONARJAVA-5985 Improve S6207's logic for constructors#5512

Merged
aurelien-coet-sonarsource merged 4 commits intomasterfrom
ac/SONARJAVA-5985
Mar 5, 2026
Merged

SONARJAVA-5985 Improve S6207's logic for constructors#5512
aurelien-coet-sonarsource merged 4 commits intomasterfrom
ac/SONARJAVA-5985

Conversation

@aurelien-coet-sonarsource
Copy link
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Contributor

hashicorp-vault-sonar-prod bot commented Mar 4, 2026

SONARJAVA-5985

@aurelien-coet-sonarsource aurelien-coet-sonarsource marked this pull request as ready for review March 5, 2026 10:33
@asya-vorobeva asya-vorobeva self-requested a review March 5, 2026 12:47
Copy link
Contributor

@asya-vorobeva asya-vorobeva left a comment

Choose a reason for hiding this comment

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

  • IIUC, we are currently give up to apply the rule in cases like
record Record(String name) {
    Record(String name, String alias) {
        //some logic with name / alias
       this(name);
    }
}

Is it intentional? Do we plan to improve it in the future?

  • Don't forget to update RSpec (we change messages for this rule).

@aurelien-coet-sonarsource
Copy link
Contributor Author

  • IIUC, we are currently give up to apply the rule in cases like
record Record(String name) {
    Record(String name, String alias) {
        //some logic with name / alias
       this(name);
    }
}

Is it intentional? Do we plan to improve it in the future?

  • Don't forget to update RSpec (we change messages for this rule).

Yes, it is intentional because we only want to raise an issue on the exact equivalent of a default constructor. Here the custom constructor doesn't match the default one because it has two parameters instead of only one for name.

There is nothing to update in RSpec because it doesn't include the messages that are raised for the issue, and the description already matches the behaviour implemented here (the previous implementation actually didn't match RSpec).

Copy link
Contributor

@asya-vorobeva asya-vorobeva left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqube-next
Copy link

sonarqube-next bot commented Mar 5, 2026

@aurelien-coet-sonarsource aurelien-coet-sonarsource merged commit b3407bb into master Mar 5, 2026
14 checks passed
@aurelien-coet-sonarsource aurelien-coet-sonarsource deleted the ac/SONARJAVA-5985 branch March 5, 2026 15:57
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.

2 participants