Skip to content

Fail build on wildcard imports#18

Merged
dbwiddis merged 2 commits intoopensearch-project:mainfrom
dbwiddis:starimport
Jun 20, 2022
Merged

Fail build on wildcard imports#18
dbwiddis merged 2 commits intoopensearch-project:mainfrom
dbwiddis:starimport

Conversation

@dbwiddis
Copy link
Copy Markdown
Member

Signed-off-by: Daniel Widdis widdis@gmail.com

Description

Fails the build if a regex matching a wildcard import is encountered.

Issues Resolved

Closes #3

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Daniel Widdis <widdis@gmail.com>
Copy link
Copy Markdown
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

What about pulling in checkstyle to enforce this [check] instead of writing it on your own(https://checkstyle.org/config_imports.html#AvoidStarImport)?

@owaiskazi19
Copy link
Copy Markdown
Member

What about pulling in checkstyle to enforce this [check] instead of writing it on your own(https://checkstyle.org/config_imports.html#AvoidStarImport)?

We have removed CheckStyle from OpenSearch to have one formatting tool(Spotless) throughout the repo and following the same here as well.

Signed-off-by: Daniel Widdis <widdis@gmail.com>
@dbwiddis dbwiddis marked this pull request as ready for review June 17, 2022 23:44
@dbwiddis dbwiddis requested a review from a team June 17, 2022 23:44
@dbwiddis
Copy link
Copy Markdown
Member Author

Ready for review. Initial test failure after adding the check. Tests pass after removing star imports in c0f119d

@dbwiddis
Copy link
Copy Markdown
Member Author

Note: the error message isn't very informative and I had to hunt down the star imports; however, for future failures they'll likely be part of the diff and much easier to identify. It may be possible to get line numbers but that adds some complexity.

@peternied
Copy link
Copy Markdown
Member

We have removed CheckStyle from OpenSearch to have one formatting tool(Spotless) throughout the repo and following the same here as well.

From opensearch-project/OpenSearch#1362, I see 'it caused issue on plugins side '. Seems like this is a cause of tight build system coupling rather than the tool itself being a problem.

While I agree that removing * imports is a good thing, lack of built-in IDE integration and a host of features that might need to be duplicated for future coverage will be the cost of this pattern.

@dbwiddis
Copy link
Copy Markdown
Member Author

From opensearch-project/OpenSearch#1362, I see 'it caused issue on plugins side '. Seems like this is a cause of tight build system coupling rather than the tool itself being a problem.

I'm not familiar with the background of the decision to remove Checkstyle from Opensearch and wonder if it could be considered to be brought back for some specific "style" checks that Spotless doesn't do. Spotless is mostly a formatting tool, while Checkstyle also checks things like redundant modifiers, variable naming conventions, etc.

While I agree that removing * imports is a good thing, lack of built-in IDE integration and a host of features that might need to be duplicated for future coverage will be the cost of this pattern.

Not sure how integrated checkstyle is? Don't most IDEs already have an easily toggleable option to remove * imports?

Copy link
Copy Markdown
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Keeping this commit unblocked for merging to keep progress moving on this pull request. If we encounter 'checks' that are already implemented via checkstyle, I think it might be worthwhile to revisit some of these comments.

Thanks for the great back-and-forth @dbwiddis

@dbwiddis dbwiddis merged commit 0488ff8 into opensearch-project:main Jun 20, 2022
@dbwiddis dbwiddis deleted the starimport branch June 20, 2022 19:42
@owaiskazi19
Copy link
Copy Markdown
Member

From opensearch-project/OpenSearch#1362, I see 'it caused issue on plugins side '. Seems like this is a cause of tight build system coupling rather than the tool itself being a problem.

We wanted to have only one formatting tool for OpenSearch and that's why asked the Plugin teams to follow the same. Does CheckStyle provides more benefits than Spotless? Something we can think of for the future definitely.

caokyhieu pushed a commit to caokyhieu/opensearch-sdk-java that referenced this pull request Aug 15, 2025
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.

[BUG] Fail build when * imports are used

3 participants