Code review changes

All overridden methods are ignored now.
This commit is contained in:
Shubham
2019-01-28 20:51:06 +05:30
parent 1b9e63b4f4
commit 746dc4e602
2 changed files with 26 additions and 25 deletions

View File

@ -80,26 +80,28 @@ public class LinguisticNamingRule extends AbstractIgnoredAnnotationRule {
@Override
public Object visit(ASTMethodDeclaration node, Object data) {
String nameOfMethod = node.getMethodName();
if (!hasIgnoredAnnotation(node)) {
String nameOfMethod = node.getMethodName();
if (getProperty(CHECK_BOOLEAN_METHODS)) {
checkBooleanMethods(node, data, nameOfMethod);
}
if (getProperty(CHECK_SETTERS)) {
checkSetters(node, data, nameOfMethod);
}
if (getProperty(CHECK_GETTERS)) {
checkGetters(node, data, nameOfMethod);
}
if (getProperty(CHECK_PREFIXED_TRANSFORM_METHODS)) {
checkPrefixedTransformMethods(node, data, nameOfMethod);
}
if (getProperty(CHECK_TRANSFORM_METHODS)) {
checkTransformMethods(node, data, nameOfMethod);
if (getProperty(CHECK_BOOLEAN_METHODS)) {
checkBooleanMethods(node, data, nameOfMethod);
}
if (getProperty(CHECK_SETTERS)) {
checkSetters(node, data, nameOfMethod);
}
if (getProperty(CHECK_GETTERS)) {
checkGetters(node, data, nameOfMethod);
}
if (getProperty(CHECK_PREFIXED_TRANSFORM_METHODS)) {
checkPrefixedTransformMethods(node, data, nameOfMethod);
}
if (getProperty(CHECK_TRANSFORM_METHODS)) {
checkTransformMethods(node, data, nameOfMethod);
}
}
return data;
@ -140,12 +142,10 @@ public class LinguisticNamingRule extends AbstractIgnoredAnnotationRule {
}
private void checkSetters(ASTMethodDeclaration node, Object data, String nameOfMethod) {
if (!hasIgnoredAnnotation(node)) {
ASTResultType resultType = node.getResultType();
if (hasPrefix(nameOfMethod, "set") && !resultType.isVoid()) {
addViolationWithMessage(data, node, "Linguistics Antipattern - The setter ''{0}'' should not return any type except void linguistically",
new Object[] { nameOfMethod });
}
ASTResultType resultType = node.getResultType();
if (hasPrefix(nameOfMethod, "set") && !resultType.isVoid()) {
addViolationWithMessage(data, node, "Linguistics Antipattern - The setter ''{0}'' should not return any type except void linguistically",
new Object[] { nameOfMethod });
}
}

View File

@ -555,6 +555,7 @@ public class AtomicBooleanFN {
<test-code>
<description>#1543 [java] LinguisticNaming should ignore overriden methods</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>4</expected-linenumbers>
<code><![CDATA[
class Foo {
private int value;