Issue #2694: Fixing AbbreviationAsWordInName incorrectly reports constants in annotations
This commit is contained in:
parent
22779281e6
commit
9130eceb98
|
|
@ -244,17 +244,18 @@ public class AbbreviationAsWordInNameCheck extends Check {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that variable definition in interface definition.
|
||||
* Check that variable definition in interface or @interface definition.
|
||||
* @param variableDefAst variable definition.
|
||||
* @return true if variable definition(variableDefAst) is in interface
|
||||
* definition.
|
||||
* or @interface definition.
|
||||
*/
|
||||
private static boolean isInterfaceDeclaration(DetailAST variableDefAst) {
|
||||
boolean result = false;
|
||||
final DetailAST astBlock = variableDefAst.getParent();
|
||||
final DetailAST astParent2 = astBlock.getParent();
|
||||
|
||||
if (astParent2.getType() == TokenTypes.INTERFACE_DEF) {
|
||||
if (astParent2.getType() == TokenTypes.INTERFACE_DEF
|
||||
|| astParent2.getType() == TokenTypes.ANNOTATION_DEF) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -292,6 +292,10 @@ public class AbbreviationAsWordInNameCheckTest extends BaseCheckTestSupport {
|
|||
"88: " + getWarningMessage("FIleNameFormatException", expectedCapitalCount),
|
||||
"90: " + getWarningMessage("serialVersionUID", expectedCapitalCount),
|
||||
"98: " + getWarningMessage("userID", expectedCapitalCount),
|
||||
"107: " + getWarningMessage("VALUE", expectedCapitalCount),
|
||||
"111: " + getWarningMessage("VALUE", expectedCapitalCount),
|
||||
"115: " + getWarningMessage("VALUE", expectedCapitalCount),
|
||||
"119: " + getWarningMessage("VALUE", expectedCapitalCount),
|
||||
};
|
||||
verify(checkConfig,
|
||||
getPath("InputAbbreviationAsWordInTypeName.java"), expected);
|
||||
|
|
|
|||
|
|
@ -102,3 +102,19 @@ class StateX {
|
|||
return this.scaleX;
|
||||
}
|
||||
}
|
||||
|
||||
@interface Annotation1 {
|
||||
String VALUE = "value"; // in @interface this is final/static
|
||||
}
|
||||
|
||||
@interface Annotation2 {
|
||||
static String VALUE = "value"; // in @interface this is final/static
|
||||
}
|
||||
|
||||
@interface Annotation3 {
|
||||
final String VALUE = "value"; // in @interface this is final/static
|
||||
}
|
||||
|
||||
@interface Annotation4 {
|
||||
final static String VALUE = "value"; // in @interface this is final/static
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue