You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2022/07/19 22:16:50 UTC

[solr] branch branch_9x updated: enable check to prevent java wildcard imports (#942)

This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new f7d476fa0cc enable check to prevent java wildcard imports (#942)
f7d476fa0cc is described below

commit f7d476fa0cc21165833340586619fc95aee420d4
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Tue Jul 19 18:16:02 2022 -0400

    enable check to prevent java wildcard imports (#942)
---
 gradle/validation/spotless.gradle | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gradle/validation/spotless.gradle b/gradle/validation/spotless.gradle
index af14da98bd7..daee2561b2c 100644
--- a/gradle/validation/spotless.gradle
+++ b/gradle/validation/spotless.gradle
@@ -62,6 +62,14 @@ configure(project(":solr").subprojects) { prj ->
             target "modules/**/examples/*.java"
             break
         }
+
+        custom 'Refuse wildcard imports', {
+          // Wildcard imports can't be resolved by spotless itself.
+          // This will require the developer themselves to adhere to best practices.
+          if (it =~ /\nimport .*\*;/) {
+            throw new AssertionError("Do not use wildcard imports.  'spotlessApply' cannot resolve this issue.")
+          }
+        }
       }
     }