rmuir commented on code in PR #14812: URL: https://github.com/apache/lucene/pull/14812#discussion_r2155783331
########## gradle/validation/ast-grep/rules/java-patterns.yml: ########## @@ -0,0 +1,24 @@ +# Banned Lucene source patterns +# Historically implemented as regexes which are more difficult +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/java_rule.json +id: java-lang-import +language: java +rule: + pattern: import java.lang.$REF + kind: import_declaration +fix: "" Review Comment: example of rule with a "fix". If it is safe and easy, it can make things nice, especially if rule is on the nitpicky side. * in editor it will show up as light-bulb, user can choose fix as a code action. * `scan -U` could be integrated if we wanted for some reason. though i'd recommend "tidy" after any such thing. * error messages improve, the problem+fix displays as diff, which helps clarify the issue: ``` > Task :applyAstGrepRules lucene/core/src/java/org/apache/lucene/index/IndexWriter.java error[java-lang-import]: unnecessary import of `String` from java.lang @@ -20,7 +20,7 @@ 21 21│ 22 22│ import java.io.Closeable; 23 23│ import java.io.IOException; 24 │-import java.lang.String; 24│+ 25 25│ import java.time.Instant; 26 26│ import java.util.ArrayDeque; 27 27│ import java.util.ArrayList; Note: classes in java.lang are implicitly imported Error: 1 error(s) found in code. Help: Scan succeeded and found error level diagnostics in the codebase. > Task :applyAstGrepRules FAILED ``` -- 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-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org