All Downloads are FREE. Search and download functionalities are using the official Maven repository.

customize.coupling.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0"?>

<ruleset name="Coupling"
         xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">

    <description>
        Rules which find instances of high or inappropriate coupling between objects and packages.
    </description>

    <rule name="CouplingBetweenObjects"
          since="1.04"
          message="High amount of different objects as members denotes a high coupling"
          class="net.sourceforge.pmd.lang.java.rule.coupling.CouplingBetweenObjectsRule"
          externalInfoUrl="${pmd.website.baseurl}/rules/java/coupling.html#CouplingBetweenObjects">
        <description>
            This rule counts the number of unique attributes, local variables, and return types within an object.
            A number higher than the specified threshold can indicate a high degree of coupling.
        </description>
        <priority>3</priority>
        <example>
            <![CDATA[
import com.Blah;
import org.Bar;
import org.Bardo;

public class Foo {
   private Blah var1;
   private Bar var2;

 	//followed by many imports of unique objects
   void ObjectC doWork() {
     Bardo var55;
     ObjectA var44;
     ObjectZ var93;
     return something;
   }
}
]]>
        </example>
    </rule>

    <rule name="ExcessiveImports"
          since="1.04"
          message="A high number of imports can indicate a high degree of coupling within an object."
          class="net.sourceforge.pmd.lang.java.rule.coupling.ExcessiveImportsRule"
          externalInfoUrl="${pmd.website.baseurl}/rules/java/coupling.html#ExcessiveImports">
        <description>
            A high number of imports can indicate a high degree of coupling within an object. This rule
            counts the number of unique imports and reports a violation if the count is above the
            user-specified threshold.
        </description>
        <priority>3</priority>
        <properties>
            <property name="minimum" value="100.0"></property>
        </properties>
        <example>
            <![CDATA[
import blah.blah.Baz;
import blah.blah.Bif;
// 18 others from the same package elided
public class Foo {
 public void doWork() {}
}
      ]]>
        </example>
    </rule>

    <rule name="LooseCoupling"
          since="0.7"
          message="Avoid using implementation types like ''{0}''; use the interface instead"
          class="net.sourceforge.pmd.lang.java.rule.coupling.LooseCouplingRule"
          externalInfoUrl="${pmd.website.baseurl}/rules/java/coupling.html#LooseCoupling">
        <description>
            The use of implementation types as object references limits your ability to use alternate
            implementations in the future as requirements change. Whenever available, referencing objects
            by their interface types provides much more flexibility.
        </description>
        <priority>3</priority>
        <example>
            <![CDATA[
	// sub-optimal approach
private ArrayList list = new ArrayList();

public HashSet getFoo() {
	return new HashSet();
}

	// preferred approach
private List list = new ArrayList();

public Set getFoo() {
	return new HashSet();
}
]]>
        </example>
    </rule>
</ruleset>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy