File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
src/main/java/com/smlnskgmail/jaman/checkstyle/checks Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public void visitToken(DetailAST ast) {
4949 log (ast );
5050 }
5151 break ;
52+ case "FloatingActionButton" :
53+ if (!ast .findFirstToken (TokenTypes .IDENT ).getText ().startsWith ("fab" )) {
54+ log (ast );
55+ }
56+ break ;
5257 }
5358 }
5459 }
Original file line number Diff line number Diff line change 99
1010public class MethodObjectReturnAnnotationCheck extends AbstractCheck {
1111
12+ private static final List <String > REQUIRED_ANNOTATIONS = Arrays .asList (
13+ "NonNull" ,
14+ "Nullable"
15+ );
16+
1217 private static final String MESSAGE_KEY = "MethodObjectReturnAnnotationCheck" ;
1318
1419 private static final List <Integer > EXCLUDED_TYPES = Arrays .asList (
@@ -27,10 +32,13 @@ public class MethodObjectReturnAnnotationCheck extends AbstractCheck {
2732 public void visitToken (DetailAST ast ) {
2833 final DetailAST returnType = ast .findFirstToken (TokenTypes .TYPE );
2934 if (!EXCLUDED_TYPES .contains (returnType .getFirstChild ().getType ())) {
30- // TODO: add annotations check
3135 final DetailAST modifiers = ast .findFirstToken (TokenTypes .MODIFIERS );
3236 if (modifiers .getChildCount (TokenTypes .ANNOTATION ) == 0 ) {
3337 log (ast .getLineNo (), MESSAGE_KEY );
38+ } else {
39+ if (!REQUIRED_ANNOTATIONS .contains (modifiers .getFirstChild ().findFirstToken (TokenTypes .IDENT ).getText ())) {
40+ log (ast .getLineNo (), MESSAGE_KEY );
41+ }
3442 }
3543 }
3644 }
Original file line number Diff line number Diff line change 1010
1111public class MethodParametersAnnotationCheck extends AbstractCheck {
1212
13+ private static final List <String > REQUIRED_ANNOTATIONS = Arrays .asList (
14+ "NonNull" ,
15+ "Nullable"
16+ );
17+
1318 private static final List <Integer > EXCLUDED_TYPES = Arrays .asList (
1419 TokenTypes .LITERAL_BOOLEAN ,
1520 TokenTypes .LITERAL_CHAR ,
@@ -42,11 +47,13 @@ public void visitToken(DetailAST ast) {
4247 }
4348
4449 private boolean isInvalidParameter (DetailAST parameterAST ) {
50+ if (EXCLUDED_TYPES .contains (parameterAST .findFirstToken (TokenTypes .TYPE ).getFirstChild ().getType ())) {
51+ return false ;
52+ }
4553 final DetailAST modifiers = parameterAST .findFirstToken (TokenTypes .MODIFIERS );
46- // TODO: add annotations check
47- return modifiers != null
48- && !EXCLUDED_TYPES .contains (parameterAST .findFirstToken (TokenTypes .TYPE ).getFirstChild ().getType ())
49- && modifiers .findFirstToken (TokenTypes .ANNOTATION ) == null ;
54+ DetailAST firstAnnotation = modifiers .findFirstToken (TokenTypes .ANNOTATION );
55+ return firstAnnotation == null
56+ || !REQUIRED_ANNOTATIONS .contains (firstAnnotation .findFirstToken (TokenTypes .IDENT ).getText ());
5057 }
5158
5259 @ Override
You can’t perform that action at this time.
0 commit comments