You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "owaiskazi19 (via GitHub)" <gi...@apache.org> on 2025/04/24 19:10:37 UTC

[I] Fail spotless check for wildcard imports [lucene]

owaiskazi19 opened a new issue, #14553:
URL: https://github.com/apache/lucene/issues/14553

   ### Description
   
   Currently, several files in the codebase contain wildcard imports ([example](https://github.com/apache/lucene/blob/main/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/VectorUtilBenchmark.java#L22)). 
   
   Wildcard imports can:
   - Make it harder to track dependencies
   - Lead to naming conflicts
   - Reduce code readability
   - Make it difficult to identify unused imports
   
   OpenSearch has already implemented a check to prevent wildcard imports ([see](https://github.com/opensearch-project/OpenSearch/pull/3939)). We can adopt a similar mechanism for Lucene to enforce explicit imports.
   
   Proposed changes:
   Add a spotless rule to detect wildcard imports to avoid committing wildcard imports. Replace existing wildcard with explicit imports.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "owaiskazi19 (via GitHub)" <gi...@apache.org>.
owaiskazi19 commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2828744973

   I gave this a shot but there are bunch of auto generated files which have `*` imports. We can utilize the already such [excluded files](https://github.com/apache/lucene/blob/main/gradle/validation/spotless.gradle#L45-L82) in the custom rule to avoid running wildcard check on them.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2957853428

   It becomes a much simpler patch (to detect wildcard imports) after we apply #14764 - I'll take care of it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2828727305

   I can help with eclipse formatter. It has a limit that you set in the preference files and I think the solution is to set it to an obnoxious value (999 or something like that)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2828628206

   would love to see this: wildcard imports hamper many forms of analysis of the code: even simple use-cases such as "grep". Without the wildcards: most identifiers in the source code can be anchored to some form of definition inside the same file. Exceptions would be `java.lang.*` and files in the same package, both of which can be worked around. 
   
   So while it doesn't work as perfectly as it does in e.g. python, it is still important to allow for basic analysis of the code without fancy stuff (such as spinning up java executable and compiling it)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss closed issue #14553: Fail spotless check for wildcard imports
URL: https://github.com/apache/lucene/issues/14553


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2828723311

   I've adopted and used what opensearch came up with. It would be ideal to also fix wildcard imports - not just detect them. It should be possible with intellij or eclipse formatter somehow but I couldn't figure it out in the limited time I had. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [I] Fail spotless check for wildcard imports [lucene]

Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #14553:
URL: https://github.com/apache/lucene/issues/14553#issuecomment-2828789291

   > I can help with eclipse formatter. It has a limit that you set in the preference files and I think the solution is to set it to an obnoxious value (999 or something like that)
   
   The problem I had was to only expand wildcard imports, without touching anything else. In theory, re-applying gjf should bring the code back to the same state but in practice there were subtle differences before and after. I don't know if you fan "only" expand wildcards, without reformatting the rest of the code.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org