File tree Expand file tree Collapse file tree 4 files changed +79
-6
lines changed
build-tools/build-infra/src/main/groovy
gradle/validation/ast-grep Expand file tree Collapse file tree 4 files changed +79
-6
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,6 @@ class ValidateSourcePatternsTask extends DefaultTask {
124124 @TaskAction
125125 public void check () {
126126 def invalidPatterns = [
127- (~$/ @author\b / $) : ' @author javadoc tag' ,
128- (~$/ (?i)\b no(n|)commit\b / $) : ' nocommit' ,
129- (~$/ \b TOOD:/ $) : ' TOOD instead TODO' ,
130- (~$/ \t / $) : ' tabs instead spaces' ,
131127 (~$/ [\u 202A-\u 202E\u 2066-\u 2069]/ $) : ' misuse of RTL/LTR (https://trojansource.codes)' ,
132128 (~$/ \Q / ** \E((?: \s)|(?: \* ))* \Q{@inheritDoc}\E ((?:\s)|(?: \* ))* \Q* / \E / $) : ' {@inheritDoc} on its own is unnecessary' ,
133129 (~$/ \$ $(?:LastChanged)?Date\b / $) : ' svn keyword' ,
Original file line number Diff line number Diff line change @@ -26,8 +26,9 @@ note: add explicit typing on the RHS when using `var`
2626id : javadoc-style-license-header
2727language : java
2828rule :
29- matches : java-license
30- regex : " ^/[*][*]"
29+ all :
30+ - matches : java-license
31+ - matches : javadoc
3132 pattern : $TEXT
3233# remove extraneous stars
3334transform :
5152 stopBy : end
5253severity : error
5354message : license should be before `package` declaration
55+ ---
56+ # yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/java_rule.json
57+ id : javadoc-author-tag
58+ language : java
59+ rule :
60+ matches : javadoc
61+ regex : " @author"
62+ severity : error
63+ message : javadoc `@author` tags should not be used
64+ ---
65+ # yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/java_rule.json
66+ id : nocommit-comment
67+ language : java
68+ rule :
69+ regex : " nocommit:"
70+ any :
71+ - kind : line_comment
72+ - kind : block_comment
73+ severity : error
74+ message : all `nocommit:` comments must be resolved
75+ ---
76+ # yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/java_rule.json
77+ id : tood-comment
78+ language : java
79+ rule :
80+ regex : " TOOD:"
81+ any :
82+ - kind : line_comment
83+ - kind : block_comment
84+ pattern : $TEXT
85+ transform :
86+ NEWTEXT :
87+ replace :
88+ replace : " TOOD:"
89+ by : " TODO:"
90+ source : $TEXT
91+ fix : $NEWTEXT
92+ severity : error
93+ message : please write as `TODO:` instead
Original file line number Diff line number Diff line change @@ -41,3 +41,32 @@ valid:
4141 - |
4242 /* BLAH BLAH Unless required by applicable law BLAH BLAH */
4343 package foo;
44+ ---
45+ id : javadoc-author-tag
46+ invalid :
47+ - |
48+ /** @author foo */
49+ valid :
50+ - |
51+ // notjavadoc @author
52+ - |
53+ /* notjavadoc @author */
54+ ---
55+ id : nocommit-comment
56+ invalid :
57+ - |
58+ // nocommit: fix this
59+ - |
60+ /* nocommit: fix this */
61+ valid :
62+ - boolean nocommit = false;
63+ ---
64+ id : tood-comment
65+ invalid :
66+ - |
67+ // TOOD: fix this
68+ - |
69+ /* TOOD: fix this */
70+ valid :
71+ - |
72+ var foo = "TOOD: whatever";
Original file line number Diff line number Diff line change 1+ ---
2+ # yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/java_rule.json
3+ id : javadoc
4+ language : java
5+ rule :
6+ # detect javadoc
7+ kind : block_comment
8+ regex : " ^/[*][*]"
You can’t perform that action at this time.
0 commit comments