Finished port of Local Final name check - deleted old code
This commit is contained in:
parent
64a5413307
commit
d000ac3d7b
|
|
@ -60,8 +60,6 @@ public class Configuration
|
|||
"^f[A-Z][a-zA-Z0-9]*$");
|
||||
PATTERN_DEFAULTS.put(Defn.LOCAL_VAR_PATTERN_PROP,
|
||||
"^[a-z][a-zA-Z0-9]*$");
|
||||
PATTERN_DEFAULTS.put(Defn.LOCAL_FINAL_VAR_PATTERN_PROP,
|
||||
"^[a-z][a-zA-Z0-9]*$");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -363,18 +361,6 @@ public class Configuration
|
|||
return getRegexpProperty(Defn.LOCAL_VAR_PATTERN_PROP);
|
||||
}
|
||||
|
||||
/** @return pattern to match local final variables **/
|
||||
String getLocalFinalVarPat()
|
||||
{
|
||||
return getPatternProperty(Defn.LOCAL_FINAL_VAR_PATTERN_PROP);
|
||||
}
|
||||
|
||||
/** @return regexp to match local final variables **/
|
||||
RE getLocalFinalVarRegexp()
|
||||
{
|
||||
return getRegexpProperty(Defn.LOCAL_FINAL_VAR_PATTERN_PROP);
|
||||
}
|
||||
|
||||
/** @return the maximum constructor length **/
|
||||
int getMaxConstructorLength()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ public interface Defn
|
|||
String PUBLIC_MEMBER_PATTERN_PROP = "checkstyle.pattern.publicmember";
|
||||
/** property name for the method local variable pattern **/
|
||||
String LOCAL_VAR_PATTERN_PROP = "checkstyle.pattern.localvar";
|
||||
/** property name for the method local final variable pattern **/
|
||||
String LOCAL_FINAL_VAR_PATTERN_PROP = "checkstyle.pattern.localfinalvar";
|
||||
/** property name for length of constructors **/
|
||||
String MAX_CONSTRUCTOR_LENGTH_PROP = "checkstyle.maxconstructorlen";
|
||||
/** property name for allowing protected data **/
|
||||
|
|
@ -104,7 +102,6 @@ public interface Defn
|
|||
MEMBER_PATTERN_PROP,
|
||||
PUBLIC_MEMBER_PATTERN_PROP,
|
||||
LOCAL_VAR_PATTERN_PROP,
|
||||
LOCAL_FINAL_VAR_PATTERN_PROP,
|
||||
};
|
||||
|
||||
/** All the integer properties */
|
||||
|
|
|
|||
|
|
@ -254,9 +254,6 @@ class Verifier
|
|||
{
|
||||
if (inMethodBlock()) {
|
||||
if (aVar.getModifierSet().containsFinal()) {
|
||||
checkVariable(aVar,
|
||||
mConfig.getLocalFinalVarRegexp(),
|
||||
mConfig.getLocalFinalVarPat());
|
||||
}
|
||||
else {
|
||||
checkVariable(aVar,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class LocalFinalVariableNameCheck
|
|||
{
|
||||
final DetailAST modifiersAST
|
||||
= aAST.findFirstToken(TokenTypes.MODIFIERS);
|
||||
final boolean isFinal = modifiersAST != null
|
||||
final boolean isFinal = (modifiersAST != null)
|
||||
&& modifiersAST.branchContains(TokenTypes.FINAL);
|
||||
|
||||
return (isFinal && ScopeUtils.inCodeBlock(aAST));
|
||||
|
|
|
|||
|
|
@ -298,7 +298,6 @@ public class CheckerTest
|
|||
mProps.setProperty(Defn.MEMBER_PATTERN_PROP, "^m[A-Z][a-zA-Z0-9]*$");
|
||||
mProps.setProperty(Defn.TODO_PATTERN_PROP, "FIXME:");
|
||||
mProps.setProperty(Defn.MEMBER_PATTERN_PROP, "^m[A-Z][a-zA-Z0-9]*$");
|
||||
mProps.setProperty(Defn.LOCAL_FINAL_VAR_PATTERN_PROP, "[A-Z]+");
|
||||
final Checker c = createChecker();
|
||||
final String filepath = getPath("InputSimple.java");
|
||||
assertNotNull(c);
|
||||
|
|
@ -309,7 +308,6 @@ public class CheckerTest
|
|||
filepath + ":71:30: ',' is not followed by whitespace.",
|
||||
filepath + ":103: Constructor length is 10 lines (max allowed is 9).",
|
||||
filepath + ":119:13: Name 'ABC' must match pattern '^[a-z][a-zA-Z0-9]*$'.",
|
||||
filepath + ":122:19: Name 'cde' must match pattern '[A-Z]+'.",
|
||||
filepath + ":130:18: Name 'I' must match pattern '^[a-z][a-zA-Z0-9]*$'.",
|
||||
filepath + ":132:20: Name 'InnerBlockVariable' must match pattern '^[a-z][a-zA-Z0-9]*$'.",
|
||||
filepath + ":161: Comment matches to-do format 'FIXME:'.",
|
||||
|
|
|
|||
|
|
@ -22,5 +22,19 @@ public class LocalFinalVariableNameCheckTest
|
|||
};
|
||||
verify(c, fname, expected);
|
||||
}
|
||||
|
||||
public void testSet()
|
||||
throws Exception
|
||||
{
|
||||
final CheckConfiguration checkConfig = new CheckConfiguration();
|
||||
checkConfig.setClassname(LocalFinalVariableNameCheck.class.getName());
|
||||
checkConfig.addProperty("format", "[A-Z]+");
|
||||
final Checker c = createChecker(checkConfig);
|
||||
final String fname = getPath("InputSimple.java");
|
||||
final String[] expected = {
|
||||
"122:19: Name 'cde' must match pattern '[A-Z]+'.",
|
||||
};
|
||||
verify(c, fname, expected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue