You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a template rule that prohibits the usage of particular classes within the java project:
<rulename="AvoidProhibitedClasses"since="0.1.0"language="java"message="The {0} class is prohibited to use."class="net.sourceforge.pmd.lang.rule.XPathRule">
<properties>
<propertyname="fullName"type="List[String]"delimiter="|"value="org.apache.commons.codec.CharEncoding|org.apache.commons.lang3.CharEncoding|org.apache.commons.lang.CharEncoding|org.apache.log4j.Logger"/>
<propertyname="shortName"type="List[String]"value="CharEncoding|Logger"/>
<propertyname="version"value="2.0"/>
<propertyname="xpath">
...
</property>
</rule>
and the rule will throw the violation for the case below:
public ... ... {
public ... ...(...) ... {
Charsetcs = Charset.forName(CharEncoding.UTF_8); // violation due to CharEncoding
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Why?
We need a template rule that prohibits the usage of particular classes within the java project:
and the rule will throw the violation for the case below:
Beta Was this translation helpful? Give feedback.
All reactions