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

com.qulice.pmd.ruleset.xml Maven / Gradle / Ivy

<?xml version="1.0"?>
<!--
 *
 * Copyright (c) 2011-2017, Qulice.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met: 1) Redistributions of source code must retain the above
 * copyright notice, this list of conditions and the following
 * disclaimer. 2) Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided
 * with the distribution. 3) Neither the name of the Qulice.com nor
 * the names of its contributors may be used to endorse or promote
 * products derived from this software without specific prior written
 * permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @version $Id$
 -->
<ruleset name="Qulice Ruleset"
         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>
        This ruleset checks code for potential mess
    </description>

    <rule ref="rulesets/java/basic.xml">
        <exclude name="AvoidThreadGroup"/>
    </rule>
    <rule ref="rulesets/java/empty.xml">
        <exclude name="EmptyCatchBlock"/>
    </rule>
    <rule ref="rulesets/java/braces.xml">
        <exclude name="IfStmtsMustUseBraces"/>
    </rule>
    <rule ref="rulesets/java/clone.xml"/>
    <rule ref="rulesets/java/codesize.xml"/>

    <rule ref="rulesets/java/design.xml">
        <exclude name="AbstractClassWithoutAbstractMethod"/>
    </rule>

    <rule ref="rulesets/java/finalizers.xml"/>

    <rule ref="rulesets/java/imports.xml">
        <exclude name="TooManyStaticImports"/>
    </rule>

    <rule ref="rulesets/java/j2ee.xml">
        <exclude name="DoNotUseThreads"/>
    </rule>
    <rule ref="rulesets/java/javabeans.xml">
        <exclude name="BeanMembersShouldSerialize"/>
    </rule>
    <rule ref="rulesets/java/logging-java.xml">
        <exclude name="GuardLogStatementJavaUtil"/>
    </rule>
    <rule ref="rulesets/java/optimizations.xml">
        <exclude name="AvoidInstantiatingObjectsInLoops"/>
    </rule>

    <rule ref="rulesets/java/strings.xml"/>
    <rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals">
        <properties>
            <property name="maxDuplicateLiterals">
                <value>2</value>
            </property>
            <property name="skipAnnotations">
                <value>true</value>
            </property>
        </properties>
    </rule>
    <rule ref="rulesets/java/sunsecure.xml"/>
    <rule ref="rulesets/java/unnecessary.xml">
        <exclude name="UnnecessaryFinalModifier"/>
    </rule>
    <rule ref="rulesets/java/unusedcode.xml"/>

    <rule ref="rulesets/java/coupling.xml">
        <exclude name="LoosePackageCoupling"/>
        <exclude name="LawOfDemeter"/>
    </rule>

    <rule ref="rulesets/java/controversial.xml">
        <exclude name="AtLeastOneConstructor"/>
        <exclude name="AvoidFinalLocalVariable"/>
        <exclude name="AvoidLiteralsInIfCondition"/>
        <exclude name="DataflowAnomalyAnalysis"/>
        <exclude name="UseConcurrentHashMap"/>
        <exclude name="AvoidUsingVolatile"/>
    </rule>

    <rule ref="rulesets/java/typeresolution.xml">
        <exclude name="SignatureDeclareThrowsException"/>
    </rule>

    <rule ref="rulesets/java/junit.xml">
        <exclude name="JUnitTestsShouldIncludeAssert"/>
        <exclude name="JUnitTestContainsTooManyAsserts"/>
        <exclude name="JUnitAssertionsShouldIncludeMessage"/>
    </rule>

    <rule ref="rulesets/java/naming.xml">
        <exclude name="ShortClassName"/>
        <exclude name="ShortVariable"/>
        <exclude name="ShortMethodName"/>
        <exclude name="LongVariable"/>
        <exclude name="AvoidFieldNameMatchingMethodName"/>
        <exclude name="AbstractNaming"/>
    </rule>

    <rule ref="rulesets/java/strictexception.xml">
        <exclude name="SignatureDeclareThrowsException"/>
    </rule>

    <rule ref="rulesets/jsp/basic-jsf.xml"/>

    <rule name="UnnecessaryLocalRule"
          message="Avoid creating unnecessary local variables like ''{0}''"
          class="com.qulice.pmd.rules.UnnecessaryLocalRule">
    </rule>

    <!-- TODO: Consider removing the 2 checks below-->

    <!-- TODO: the check reports errors on inner classes' constants, fix or remove it. -->
    <rule name="ConstructorShouldDoInitialization"
          message="Avoid doing field initialization outside constructor."
          language="java"
          class="net.sourceforge.pmd.lang.rule.XPathRule">
        <description>
            Avoid doing field initialization outside class constructor.
            Such initialization is allowed only when there is no constructor.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
                        //ClassOrInterfaceBody
                        [count(ClassOrInterfaceBodyDeclaration/ConstructorDeclaration)>0]
                        [count(ClassOrInterfaceBodyDeclaration/FieldDeclaration[@Static='false']/VariableDeclarator/VariableInitializer)>0]
                    ]]>
                </value>
            </property>
        </properties>
        <priority>3</priority>
    </rule>

    <rule name="OnlyOneConstructorShouldDoInitialization"
          message="Avoid field initialization in several constructors."
          language="java"
          class="net.sourceforge.pmd.lang.rule.XPathRule">
        <description>
            Avoid doing field initialization in several constructors.
            Only one main constructor should do real work.
            Other constructors should delegate initialization to it.
        </description>
        <properties>
            <property name="xpath">
                <value>
                    <![CDATA[
                            //ClassOrInterfaceBody[count(ClassOrInterfaceBodyDeclaration/ConstructorDeclaration)>1]
                            [count(ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[BlockStatement])>1]
                    ]]>
                </value>
            </property>
        </properties>
        <priority>3</priority>
    </rule>
</ruleset>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy