<?xml version="1.0"?>

<ruleset name="Import Statement Rules"
    xmlns="http://pmd.sf.net/ruleset/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
    xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">

  <description>
These rules deal with different problems that can occur with a class' import statements.
  </description>

  <rule name="DuplicateImports"
  		  since="0.5"
        message="Avoid duplicate imports such as ''{0}''"
        class="net.sourceforge.pmd.rules.imports.DuplicateImportsRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/imports.html#DuplicateImports">
    <description>
    Avoid duplicate import statements.
    </description>
      <priority>4</priority>
    <example>
<![CDATA[
import java.lang.String;
import java.lang.*;
public class Foo {}
]]>
    </example>
    </rule>

  <rule name="DontImportJavaLang"
  		  since="0.5"
        message="Avoid importing anything from the package 'java.lang'"
        class="net.sourceforge.pmd.rules.imports.DontImportJavaLang"
          externalInfoUrl="http://pmd.sourceforge.net/rules/imports.html#DontImportJavaLang">
    <description>
Avoid importing anything from the package 'java.lang'.  These classes are automatically imported (JLS 7.5.3).
    </description>
      <priority>4</priority>
    <example>
<![CDATA[
// this is bad
import java.lang.String;
public class Foo {}

// --- in another source code file...

// this is bad
import java.lang.*;

public class Foo {}
]]>
    </example>
    </rule>

  <rule name="UnusedImports"
  		  since="1.0"
        message="Avoid unused imports such as ''{0}''"
        class="net.sourceforge.pmd.rules.imports.UnusedImportsRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/imports.html#UnusedImports">
    <description>
    Avoid unused import statements.
    </description>
      <priority>4</priority>
    <example>
<![CDATA[
// this is bad
import java.io.File;
public class Foo {}
]]>
    </example>
    </rule>

    <rule name="ImportFromSamePackage"
    		since="1.02"
         message="No need to import a type that lives in the same package"
         class="net.sourceforge.pmd.rules.imports.ImportFromSamePackageRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/imports.html#ImportFromSamePackage">
     <description>
 No need to import a type that lives in the same package.
     </description>
        <priority>3</priority>
     <example>
 <![CDATA[
 package foo;
 import foo.Buz; // no need for this
 import foo.*; // or this
 public class Bar{}
 ]]>
     </example>
     </rule>

	<rule	name="TooManyStaticImports"
	      since="4.1"
        	class="net.sourceforge.pmd.rules.XPathRule"
        	message="Too many static imports may lead to messy code"
       		externalInfoUrl="http://pmd.sourceforge.net/rules/imports.html#TooManyStaticImports">
       		<description><![CDATA[
If you overuse the static import feature, it can make your program unreadable and 
unmaintainable, polluting its namespace with all the static members you import. 
Readers of your code (including you, a few months after you wrote it) will not know 
which class a static member comes from (Sun 1.5 Language Guide).
		 ]]></description>
			<priority>3</priority>
       		<properties>
	            <property name="xpath">
	                <value><![CDATA[
.[count(ImportDeclaration[@Static = 'true']) > $maximumStaticImports]
	             ]]></value>
	            </property>
	            <property name="maximumStaticImports" 
	            description="All static imports can be disallowed by setting this to 0">
	            	<value>4</value>
	            </property>
	        </properties>
    	 	<example><![CDATA[
import static Lennon;
import static Ringo;
import static George;
import static Paul;
import static Yoko; // Too much !
		  ]]></example>
    </rule>

</ruleset>
