Change rule message, commit useful changes

This commit is contained in:
Clément Fournier committed 2022-01-02 15:38:05 +01:00
1 parent 58a7c520d2
commit fd1ff06f08
2 files changed
+26 -1

No files matched your search

@@ -4,6 +4,10 @@
package net.sourceforge.pmd.lang.java.ast;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A unary operator, either prefix or postfix. This is used by {@link ASTUnaryExpression UnaryExpression}
* to abstract over the syntactic form of the operator.
@@ -96,4 +100,25 @@ public enum UnaryOp implements InternalInterfaces.OperatorLike {
return this.code;
}
/**
* Tests if the node is an {@link ASTUnaryExpression} with one of the given operators.
*/
public static boolean isUnaryExprWithOperator(@Nullable JavaNode e, Set<UnaryOp> operators) {
if (e instanceof ASTUnaryExpression) {
ASTUnaryExpression unary = (ASTUnaryExpression) e;
return operators.contains(unary.getOperator());
}
return false;
}
/**
* Tests if the node is an {@link ASTUnaryExpression} with the given operator.
*/
public static boolean isUnaryExprWithOperator(@Nullable JavaNode e, UnaryOp operator) {
if (e instanceof ASTUnaryExpression) {
ASTUnaryExpression unary = (ASTUnaryExpression) e;
return operator == unary.getOperator();
}
return false;
}
}
@@ -451,7 +451,7 @@ try { // Prefer this:
<rule name="AvoidLiteralsInIfCondition"
language="java"
since="4.2.6"
message="Avoid using Literals in Conditional Statements"
message="Avoid using literals in if statements"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
<description>