Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 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,35 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
</property>
</properties>
</rule>
<!-- /**
* @Todo Add tests cases for ConstantsOnRightSideOfComparison rule to ensure it works properly
*/ -->
<rule name="ConstantsOnRightSideOfComparison" language="java" message="Constants should be on the right side of comparisons." class="net.sourceforge.pmd.lang.rule.XPathRule">
<description>
Enforces the code style guideline that constants (null or numbers) should appear on the right side of comparison operators ('==' and '!=') to reduce the risk of accidental assignment and improve readability.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//EqualityExpression[
(
(
PrimaryExpression/PrimaryPrefix/Literal[@Float='true' or @Double='true' or @Int='true' or @Long='true']
or
PrimaryExpression/PrimaryPrefix/Name[@Image='null']
)
and
PrimaryExpression/PrimarySuffix
)
and
(
./EqualityExpression[@Image='==' or @Image='!=']
)
]
[not(./PrimaryExpression[1]/PrimaryPrefix/Literal[@Float='true' or @Double='true' or @Int='true' or @Long='true'] or ./PrimaryExpression[1]/PrimaryPrefix/Name[@Image='null'])]
]]></value>
</property>
</properties>
</rule>
</ruleset>