Avoid static imports and add the related checkstyle
See original GitHub issueI think that sometimes the code is not so readable using static imports.
An example is here using just sigleton
which seems not to be clear coming from Collections
but could be a private method in the class.
Of course, using an IDE you have all the facilities to get that but it’s not the same while reviewing on GitHub.
As mentioned by @tombentley I would propose to avoid using static imports and adding the related checkstyle https://checkstyle.sourceforge.io/config_imports.html#AvoidStaticImport.
It’s more a refactoring work.
Of course, it’s possible that my opinion is not commonly shared with the other @strimzi/maintainers so if Tom is ok to stick with static imports, what the others think?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
AvoidStaticImportCheck (checkstyle 10.5.0 API)
Checks that there are no static import statements. Rationale: Importing static members can lead to naming conflicts between class' members.
Read more >What is a good use case for static import of methods?
Use static imports only when you were tempted to "abuse inheritance". In this case, would you have been tempted to have BusinessObject extend...
Read more >Imports - Checkstyle
Checks that there are no static import statements. Rationale: Importing static members can lead to naming conflicts between class' members. It may lead...
Read more >checkstyle – Imports
Checks that there are no import statements that use the * notation. Rationale: Importing all classes from a package or static members from...
Read more >Avoid static imports - Carlos Becker
Importing all of the static members from a class can be particularly harmful to readability; if you need only one or two members,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think in general static imports should be allowed in test code. Maybe not so in non-test code? with certain ModelUtils exceptions.
I quite like allowing static imports for HamCrest matchers as
is better than
Since matchers are always nested inside assertThats i see no ambiguity as to which class they came from.