Skip to content

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Feb 9, 2025

prerequisite: #46149

resolve: #45898

apply: https://checkstyle.sourceforge.io/checks/imports/avoidstarimport.html#Example1-config

This change would address the issue of wildcard imports and reduce the effort for new developers, as well as for those (like myself) who need to reference the documentation before committing. It would help reduce noise and friction, making things work out of the box and more self-explanatory.

@rhusar @gastaldi

@Pankraz76 Pankraz76 marked this pull request as ready for review February 9, 2025 11:38
@Pankraz76 Pankraz76 force-pushed the maven-checkstyle-plugin-AvoidStarImport branch from da16c88 to 4e86afd Compare February 9, 2025 11:40
<module name="TreeWalker">
<module name="AvoidStarImport"/>
</module>
<!-- <module name="LineLength">-->
Copy link
Author

Choose a reason for hiding this comment

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

This needs to be discussed and either removed or addressed step by step, as it is currently not compliant.

@Pankraz76 Pankraz76 force-pushed the maven-checkstyle-plugin-AvoidStarImport branch from 4e86afd to 1e57060 Compare February 9, 2025 15:26
.editorconfig Outdated
end_of_line = lf
indent_style = space
insert_final_newline = false
max_line_length = 120
Copy link
Author

Choose a reason for hiding this comment

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

this of course needs to be adjust to your needs as idk the defaults here around i suggested the imho most common.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

thx

Copy link
Author

Choose a reason for hiding this comment

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

Reconsidering this, IMHO, it only makes sense again with the corresponding editorconfig-maven-plugin, as this ensures that the theory (config) is applied in reality (code) as seen here: https://github.com/urlaubsverwaltung/urlaubsverwaltung/blob/5350de17c6ba9b0b1d60e983bb2642b479c5d8bb/pom.xml#L418

Although this is only meant to be an addition to the current Eclipse formatter, as this lacks the end_of_line = lf config, or I don’t see it.

Just blocking out the star imports would be compatible and minimally invasive, only causing attention in a really avoidable situation.

@gastaldi
Copy link
Contributor

I like the .editorconfig, but IMHO introducing Checkstyle needs to be discussed in a separate PR

@Pankraz76
Copy link
Author

Pankraz76 commented Feb 12, 2025

Thanks for the feedback. The goal was to introduce a seamless, out-of-the-box solution for coding guidelines, reducing manual code formatting evaluation, which is time-consuming and error-prone.

  • .editorconfig helps maintain alignment with coding rules but only works if auto-formatting is enabled locally (not default).
  • .editorconfig prevents auto-optimization but doesn’t fail the build if forbidden wildcard imports are manually committed.
  • Checkstyle plugin is the only tool capable of blocking disallowed imports.
  • A fail-fast, fail-early approach ensures immediate local feedback for non-compliant code.

Checkstyle is opinionated but only enforces configured rules. Currently, we only enforce one rule: forbidden wildcard imports.

A hybrid solution could enforce critical rules with Checkstyle while leaving other aspects untouched, reducing manual effort.

@Pankraz76 Pankraz76 force-pushed the maven-checkstyle-plugin-AvoidStarImport branch from 1e57060 to 6942fa8 Compare February 12, 2025 09:07
@Pankraz76 Pankraz76 force-pushed the maven-checkstyle-plugin-AvoidStarImport branch from 6942fa8 to a03e5db Compare February 12, 2025 09:08
@Pankraz76 Pankraz76 changed the title Avoid wildcard * import via maven-checkstyle-plugin introduce AvoidStarImport rule via maven-checkstyle-plugin Feb 12, 2025
@gastaldi
Copy link
Contributor

We know that ChatGPT is useful, but please refrain from using it to explain every change you did, that's a bit annoying

@Pankraz76
Copy link
Author

yes please excuse this, as im having some kind of difficulties with the language and syntax. I will try to imporve.

@gastaldi
Copy link
Contributor

Sorry, introducing Checkstyle requires an ADR and previous discussion, we're closing this PR for now.

@gastaldi gastaldi closed this Feb 12, 2025
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Feb 12, 2025
@Pankraz76
Copy link
Author

ADR: #46247

@Pankraz76
Copy link
Author

Pankraz76 commented May 18, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/maven triage/invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apply convention over configuration principle to prevent wildcard imports

2 participants