enum - private constructor - Remove this unused private "ClassName" constructor.

559 views
Skip to first unread message

roman...@gmail.com

unread,
Jun 6, 2018, 10:43:10 AM6/6/18
to SonarQube
hi,

Is this a false positive?

public enum ClassName {
...
   private ClassName(final String a){}
Remove this unused private "ClassName" constructor.
}

As far as I understand the private keyword could be flagged as redundant (also see https://groups.google.com/d/msg/sonarqube/3CyehW9fqkg/CnzqMJd9BAAJ).
But enums should probably be an exception to squid:UnusedPrivateMethod.

kind regards,
Roman

sonarqube: 7.1.0.11001
SonarJava 5.3

Michael Gumowski

unread,
Jun 7, 2018, 4:42:50 AM6/7/18
to roman...@gmail.com, SonarQube
Hello Roman,

Thanks for the feedback. Unfortunately I'm not able to reproduce the issue on my side with your example. I think you may have simplified a bit too much your reproducer, because this case should be handled correctly by the rule. Maybe the constructor is unresolved by our semantic engine, but in order to confirm that, I would need a bit more.

Could you provide a small self-contained code snippet reproducing the issue systematically?

Regarding the redundant modifier issue not being raised, this should be already handled perfectly by rule S2333. However the rule is not part of the default SonarWay quality profile. So if you are using SonarWay, the rule is most probably simply not enabled.

Cheers,
Michael

--
Important: this SonarQube Google Group will close on June 11th, 2018, in order to move to a new forum to power even more community discussions. See details in this post: https://groups.google.com/d/msg/sonarqube/BbSZz-JnhVM/DavhMueEAAAJ
---
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/502c74b7-a104-484d-a77f-b3102eb34bf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
https://www.sonarsource.com
Reply all
Reply to author
Forward
0 new messages