Skip to content

Commit 221b9f4

Browse files
authored
Merge pull request #2 from fartem/1.2.0
2021-04-03 Version 1.2.0: Updated checks
2 parents 5250605 + 57fe9d6 commit 221b9f4

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Add to `TreeWalker` module:
4242
<module name="com.smlnskgmail.jaman.checkstyle.checks.AndroidViewFieldNameCheck">
4343
<property name="id" value="AndroidViewFieldNameCheck" />
4444
</module>
45-
<module name="com.smlnskgmail.jaman.checkstyle.checks.ContextFirstParameterCheck">
45+
<module name="com.smlnskgmail.jaman.checkstyle.checks.ContextAsFirstParameterCheck">
4646
<property name="id" value="ContextFirstParameterCheck" />
4747
</module>
4848
<module name="com.smlnskgmail.jaman.checkstyle.checks.MethodObjectReturnAnnotationCheck">

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

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

1010
checkstyle {
1111
toolVersion '8.38'

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@ public void visitToken(DetailAST ast) {
1414
if (identifier != null) {
1515
String fieldClassName = identifier.getText();
1616
switch (fieldClassName) {
17+
case "LinearLayout":
18+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("lv")) {
19+
log(ast);
20+
}
21+
break;
22+
case "RelativeLayout":
23+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("rl")) {
24+
log(ast);
25+
}
26+
break;
27+
case "ConstraintLayout":
28+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("cl")) {
29+
log(ast);
30+
}
31+
break;
32+
case "FrameLayout":
33+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("fl")) {
34+
log(ast);
35+
}
36+
break;
37+
case "ScrollView":
38+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("sv")) {
39+
log(ast);
40+
}
41+
break;
42+
case "HorizontalScrollView":
43+
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("hsv")) {
44+
log(ast);
45+
}
46+
break;
1747
case "TextView":
1848
if (!ast.findFirstToken(TokenTypes.IDENT).getText().startsWith("tv")) {
1949
log(ast);

src/main/java/com/smlnskgmail/jaman/checkstyle/checks/ContextFirstParameterCheck.java renamed to src/main/java/com/smlnskgmail/jaman/checkstyle/checks/ContextAsFirstParameterCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import com.puppycrawl.tools.checkstyle.api.DetailAST;
55
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
66

7-
public class ContextFirstParameterCheck extends AbstractCheck {
7+
public class ContextAsFirstParameterCheck extends AbstractCheck {
88

9-
private static final String MESSAGE_KEY = "ContextFirstParameterCheck";
9+
private static final String MESSAGE_KEY = "ContextAsFirstParameterCheck";
1010

1111
@Override
1212
public void visitToken(DetailAST ast) {

0 commit comments

Comments
 (0)