Skip to content
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

Add a private constructor to hide the implicit public ones in Utility classes #741

Closed
rohanKanojia opened this issue Jun 28, 2021 · 1 comment · Fixed by #749
Closed
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rohanKanojia
Copy link
Member

Utility classes, which are collections of static members, are not meant to be instantiated. Even abstract utility classes, which can be extended, should not have public constructors.

Java adds an implicit public constructor to every class which does not define at least one explicitly. Hence, at least one non-public constructor should be defined. You can read more about this in SonarRule[0]

We need to update our utility classed pointed out by SonarCloud[1].

[0] https://sonarcloud.io/organizations/jkubeio/rules?open=java%3AS4042&rule_key=java%3AS4042
[1] https://sonarcloud.io/organizations/jkubeio/issues?projects=jkubeio_jkube&resolved=false&rules=java%3AS1118

@rohanKanojia rohanKanojia added good first issue Good for newcomers help wanted Extra attention is needed labels Jun 28, 2021
@kristofnagyban
Copy link
Contributor

I'll work on this.

@manusa manusa linked a pull request Jul 1, 2021 that will close this issue
12 tasks
manusa pushed a commit that referenced this issue Jul 1, 2021
* Fixes issue #741. Private constructor added to Utility classes marked in [1] https://sonarcloud.io/organizations/jkubeio/issues?projects=jkubeio_jkube&resolved=false&rules=java%3AS1118

Signed-off-by: Kristóf Nagybán <kristof.nagyban@gmail.com>

* Unwanted changes in imports reverted.

Signed-off-by: Kristóf Nagybán <kristof.nagyban@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants