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 Checkstyle Plugin to Enforce Import Rules #396

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

dariuszzbyrad
Copy link
Contributor

While analyzing the project, I found several unused and redundant import statements. To improve the code quality and ensure that best practices are followed going forward, I have added the Checkstyle plugin with rules to:

  • Detect and remove unused imports.
  • Prevent redundant imports (e.g., duplicate imports of the same class).
  • Disallow illegal imports such as sun.* packages by default.

This configuration will help maintain clean and compliant code, and the build will fail if any violations are detected.

@FDelporte
Copy link
Member

Thanks @dariuszzbyrad! I'm all in favor of cleaner code, so this looks great. Asking for second opinion to Tom and/or Eitch so we can merge this.

Copy link
Collaborator

@taartspi taartspi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 Thanks, this is a good idea to help keep the code clean.    You created a new _config_ directory with the context _checkstyle_.   Do you see more config file types  are possible and these separate directories are needed ?           Tom

@dariuszzbyrad
Copy link
Contributor Author

Yes, potentially at the config level, we could add tools like CodeNarc, PMD, SpotBugs, etc. Additionally, for Checkstyle specifically, we might include files like suppressions.xml and suppressions-cpath.xml to manage specific rule exceptions.

@taartspi
Copy link
Collaborator

Thanks for the response and the PR. Tom

@eitch
Copy link
Member

eitch commented Oct 24, 2024

The issue looks fine, but we have to bear in mind, that our resources are limited. Adding new checks and then failing the build should not be a priority. I am always willing to look at PRs with new checks, where each new check is a new PR and the build doesn't fail with the new check.

If we can agree on this, then i find this a good change and am always for cleaner and better code.

Copy link
Member

@eitch eitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good

@eitch eitch merged commit 3961664 into Pi4J:develop Oct 24, 2024
1 check passed
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.

4 participants