Skip to content

Commit 206cb92

Browse files
authored
Merge pull request #3 from fartem/1.2.1
2021-04-07 Version 1.2.1: Refactored AndroidViewFieldNameCheck and up…
2 parents 221b9f4 + fde64ee commit 206cb92

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
22
id 'java'
33
id 'checkstyle'
4-
id 'de.aaschmid.cpd' version '3.1'
4+
id 'de.aaschmid.cpd' version '3.2'
55
}
66

77
group 'com.smlnskgmail.jaman.checkstyle'
8-
version '1.2.0'
8+
version '1.2.1'
99

1010
checkstyle {
11-
toolVersion '8.38'
11+
toolVersion '8.41.1'
1212
ignoreFailures false
1313
showViolations true
1414

@@ -44,5 +44,5 @@ repositories {
4444
}
4545

4646
dependencies {
47-
implementation 'com.puppycrawl.tools:checkstyle:8.38'
47+
implementation 'com.puppycrawl.tools:checkstyle:8.41.1'
4848
}

src/main/java/com/smlnskgmail/jaman/checkstyle/checks/AndroidViewFieldNameCheck.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,74 +13,75 @@ public void visitToken(DetailAST ast) {
1313
DetailAST identifier = ast.findFirstToken(TokenTypes.TYPE).findFirstToken(TokenTypes.IDENT);
1414
if (identifier != null) {
1515
String fieldClassName = identifier.getText();
16+
String ident = ast.findFirstToken(TokenTypes.IDENT).getText();
1617
switch (fieldClassName) {
1718
case "LinearLayout":
18-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("lv")) {
19+
if (!ident.startsWith("lv")) {
1920
log(ast);
2021
}
2122
break;
2223
case "RelativeLayout":
23-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("rl")) {
24+
if (!ident.startsWith("rl")) {
2425
log(ast);
2526
}
2627
break;
2728
case "ConstraintLayout":
28-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("cl")) {
29+
if (!ident.startsWith("cl")) {
2930
log(ast);
3031
}
3132
break;
3233
case "FrameLayout":
33-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("fl")) {
34+
if (!ident.startsWith("fl")) {
3435
log(ast);
3536
}
3637
break;
3738
case "ScrollView":
38-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("sv")) {
39+
if (!ident.startsWith("sv")) {
3940
log(ast);
4041
}
4142
break;
4243
case "HorizontalScrollView":
43-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("hsv")) {
44+
if (!ident.startsWith("hsv")) {
4445
log(ast);
4546
}
4647
break;
4748
case "TextView":
48-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("tv")) {
49+
if (!ident.startsWith("tv")) {
4950
log(ast);
5051
}
5152
break;
5253
case "ImageView":
53-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("iv")) {
54+
if (!ident.startsWith("iv")) {
5455
log(ast);
5556
}
5657
break;
5758
case "ImageButton":
58-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("ib")) {
59+
if (!ident.startsWith("ib")) {
5960
log(ast);
6061
}
6162
break;
6263
case "EditText":
63-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("et")) {
64+
if (!ident.startsWith("et")) {
6465
log(ast);
6566
}
6667
break;
6768
case "Button":
68-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("btn")) {
69+
if (!ident.startsWith("btn")) {
6970
log(ast);
7071
}
7172
break;
7273
case "RecyclerView":
73-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("rv")) {
74+
if (!ident.startsWith("rv")) {
7475
log(ast);
7576
}
7677
break;
7778
case "AdaptiveRecyclerView":
78-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("arv")) {
79+
if (!ident.startsWith("arv")) {
7980
log(ast);
8081
}
8182
break;
8283
case "FloatingActionButton":
83-
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("fab")) {
84+
if (!ident.startsWith("fab")) {
8485
log(ast);
8586
}
8687
break;

0 commit comments

Comments
 (0)