InnerTypeLast within methods #6
This commit is contained in:
parent
a94d50133e
commit
4c384214a9
|
|
@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.checks.design;
|
|||
|
||||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
/**
|
||||
|
|
@ -50,12 +51,10 @@ public class InnerTypeLastCheck extends Check
|
|||
}
|
||||
else {
|
||||
DetailAST nextSibling = aAST.getNextSibling();
|
||||
while (null != nextSibling
|
||||
&& ((nextSibling.getType() != TokenTypes.CLASS_DEF)
|
||||
|| (nextSibling.getType() != TokenTypes.INTERFACE_DEF)))
|
||||
{
|
||||
if (nextSibling.getType() == TokenTypes.VARIABLE_DEF
|
||||
|| nextSibling.getType() == TokenTypes.METHOD_DEF)
|
||||
while (null != nextSibling) {
|
||||
if (!ScopeUtils.inCodeBlock(aAST)
|
||||
&& (nextSibling.getType() == TokenTypes.VARIABLE_DEF
|
||||
|| nextSibling.getType() == TokenTypes.METHOD_DEF))
|
||||
{
|
||||
log(nextSibling.getLineNo(), nextSibling.getColumnNo(),
|
||||
"arrangement.members.before.inner");
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ package com.puppycrawl.tools.checkstyle.checks.design;
|
|||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class InnerTypeLastCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
|
|
@ -31,17 +32,11 @@ public class InnerTypeLastCheckTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(InnerTypeLastCheck.class);
|
||||
final String[] expected = {
|
||||
"15:17: Fields and methods should be before inner classes.",
|
||||
"25:17: Fields and methods should be before inner classes.",
|
||||
"26:17: Fields and methods should be before inner classes.",
|
||||
"39:25: Fields and methods should be before inner classes.",
|
||||
"40:25: Fields and methods should be before inner classes.",
|
||||
"44:9: Fields and methods should be before inner classes.",
|
||||
"60:25: Fields and methods should be before inner classes.",
|
||||
"61:25: Fields and methods should be before inner classes.",
|
||||
"65:9: Fields and methods should be before inner classes.",
|
||||
"69:9: Fields and methods should be before inner classes.",
|
||||
"78:5: Fields and methods should be before inner classes.",
|
||||
"95:9: Fields and methods should be before inner classes.",
|
||||
};
|
||||
verify(checkConfig, getPath("design" + File.separator
|
||||
+ "InputInnerClassCheck.java"), expected);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class InputInnerClassCheck {
|
|||
}
|
||||
}
|
||||
|
||||
int test3 = 300; //error
|
||||
int test3 = 300;
|
||||
}
|
||||
|
||||
public void methodTestInner2() {
|
||||
|
|
@ -22,8 +22,8 @@ public class InputInnerClassCheck {
|
|||
int test6 = 500;
|
||||
}
|
||||
|
||||
int test6 = 600; //error
|
||||
int test8 = 800; //error
|
||||
int test6 = 600;
|
||||
int test8 = 800;
|
||||
}
|
||||
|
||||
class Inner1 {
|
||||
|
|
@ -36,8 +36,8 @@ public class InputInnerClassCheck {
|
|||
int test10 = 500;
|
||||
}
|
||||
|
||||
int test11 = 600; //error
|
||||
int test12 = 800; //error
|
||||
int test11 = 600;
|
||||
int test12 = 800;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,8 +57,8 @@ class Temp2 {
|
|||
int test10 = 500;
|
||||
}
|
||||
|
||||
int test11 = 600; //error
|
||||
int test12 = 800; //error
|
||||
int test11 = 600;
|
||||
int test12 = 800;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,3 +80,18 @@ class Temp3 {
|
|||
return new int[]{1, };
|
||||
}
|
||||
}
|
||||
|
||||
class Temp4 {
|
||||
|
||||
class InnerCheck {
|
||||
class InnerInnerCheck {
|
||||
private int a = 0;
|
||||
}
|
||||
|
||||
class InnerInnerCheck2 {
|
||||
private int a = 0;
|
||||
}
|
||||
|
||||
private int I = 0; // error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue