Suggestion to add a SonarLint rule for detecting incorrect Map keys

Hello
I am using (with much appreciation) SonarLint 9.3 with Eclipse for my JAVA projects. I would like to suggest adding a rule to detect incorrect Map keys.

Example of incorrect use: Map<StringBuilder, Object>. StringBuilder is a class without equals/hashCode methods, so it cannot function correctly (as expected).

Cheers
Piotr

1 Like

Welcome :slight_smile:

there’s already such a Java rule for maps

The rule java:S6411 is not part of the builtin Java quality profile ‘Sonar way’, it has to be activated.
Sonarlint in standalone mode (not connected to a Sonarqube server / without project binding)
uses the builtin Java quality profile ‘Sonar way’.
AFAIK you can’t activate additonal rules when using Sonarlint standalone.

Gilbert

1 Like

Hello @Piotr_Boryszek, Hello @Rebse,

just for clarification, the rule java:S6411 is available in SonarLint standalone but not activated by default. You can enable it from Preferences → SonarLint → Rules Configuration.

Best,
Tobias

3 Likes

Wow! Thanks for the quick response and solution. I didn’t realized its build in already.
Cheers
PB

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.