Skip to content

Commit

Permalink
Fixed Constants should be on the right side of comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
LaithAlebrahim committed Mar 21, 2024
1 parent 2626cbf commit 7f20258
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,26 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
</property>
</properties>
</rule>
<rule name="ConstantsOnRightSideOfComparison" language="java" class="net.sourceforge.pmd.lang.rule.XPathRule" message="Constants should be on the right side of comparisons.">
<description>
Enforces the code style guideline that constants (null, string literals, or numbers) should appear on the right side of comparison operators to reduce the risk of accidental assignment and improve readability.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//EqualityExpression[
(
PrimaryExpression/PrimaryPrefix/Literal
or
PrimaryExpression/PrimaryPrefix/Name[@Image='null']
)
and
PrimaryExpression/PrimarySuffix
]
[not(./PrimaryExpression[1]/PrimaryPrefix/Literal or ./PrimaryExpression[1]/PrimaryPrefix/Name[@Image='null'])]
]]></value>
</property>
</properties>
</rule>
</ruleset>

0 comments on commit 7f20258

Please sign in to comment.