This change fixes "Utility classes should not have public constructors" (id = java:S1118) identified by Sonar.
Details
This change adds private constructors to utility classes. Utility classes are only meant to be accessed statically. Since they're not meant to be instantiated, we can use the Java's code visibility protections to hide the constructor and prevent unintended or malicious access.
Our changes look something like this:
public class Utils {
+ private Utils() {}
...
More reading
* [https://rules.sonarsource.com/java/RSPEC-1118/](https://rules.sonarsource.com/java/RSPEC-1118/)
I have additional improvements ready for this repo! If you want to see them, leave the comment:
Remediation
This change fixes "Utility classes should not have public constructors" (id = java:S1118) identified by Sonar.
Details
This change adds private constructors to utility classes. Utility classes are only meant to be accessed statically. Since they're not meant to be instantiated, we can use the Java's code visibility protections to hide the constructor and prevent unintended or malicious access.
Our changes look something like this:
More reading
* [https://rules.sonarsource.com/java/RSPEC-1118/](https://rules.sonarsource.com/java/RSPEC-1118/)I have additional improvements ready for this repo! If you want to see them, leave the comment:
... and I will open a new PR right away!
🧚🤖 Powered by Pixeebot
Feedback | Community | Docs | Codemod ID: sonar:java/avoid-implicit-public-constructor-s1118