Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

(Sonar) Fixed finding: "Utility classes should not have public constructors" #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

pixeebot[bot]
Copy link

@pixeebot pixeebot bot commented Apr 30, 2024

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:

   public class Utils {
+    private Utils() {}
     ...
More reading

Powered by: pixeebot (codemod ID: sonar:java/avoid-implicit-public-constructor-s1118)

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Author

pixeebot bot commented May 24, 2024

This change may not be a priority right now, so I'll close it. If there was something I could have done better, please let me know!

You can also customize me to make sure I'm working with you in the way you want.

@pixeebot pixeebot bot closed this May 24, 2024
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.

0 participants