| <?xml version="1.0"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <ruleset name="Maintanability Rules" |
| 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" |
| xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> |
| |
| <description> |
| The Maintanability ruleset contains a collection of good practices around Maintanability. |
| </description> |
| |
| <rule since="1.1" class="org.apache.flex.pmd.rules.maintanability.OnlyOneReturnRule" message="A method should have only one exit point, and that should be the last statement in the method"> |
| <priority>3</priority> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.AlertShowRule" message="Do not call Alert.show directly"> |
| <description>You should not Alert.show() directly. If an error occurred in the system, you should probably use an ErrorManager to have a consistent way to manage those errors.</description> |
| <priority>1</priority> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.ExcessiveImportRule" |
| message="A high number of imports can indicate a high degree of coupling within an object. ({0} maximum but {1} actually)"> |
| <description>A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold.</description> |
| <priority>3</priority> |
| <properties> |
| <property name="maximum"> |
| <value>15</value> |
| </property> |
| </properties> |
| <example> |
| import blah.blah.Baz; |
| import blah.blah.Bif; |
| // 18 others from the same package elided |
| public class Foo |
| { |
| public function doWork() : void |
| { |
| } |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.TrueFalseConditionRule" |
| message="This test contains a hard coded boolean value. You could remove it by having '{0}'"> |
| <priority>3</priority> |
| <example> |
| if ( true ) // VIOLATION |
| { |
| if ( myCondition == false ) // VIOLATION |
| { |
| } |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.AvoidUsingPublicStaticFieldRule" |
| message="If this field ({0}) was meant to be a constant, make it constant. Otherwise, if it is used as a global variable, you may want to redesign this class"> |
| <priority>3</priority> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.DynamicClassRule" message="A class must not be dynamic"> |
| <description>When using dynamic classes, you cannot control how the developer will use your class. It makes refactoring really difficult</description> |
| <priority>1</priority> |
| <example> |
| dynamic public class DynamicObject // VIOLATION |
| { |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.forbiddentypes.UseObjectTypeRule" |
| message="Do not use Object class"> |
| <description>It is a bad practice to use the dynamic class Object. Prefer using strongly typed object, or marker interface in order to avoid silent compilation errors while refactoring</description> |
| <priority>1</priority> |
| <example> |
| public class Foo |
| { |
| public var bar : Object; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.forbiddentypes.UseDictionaryTypeRule" |
| message="Do not use Dictionnary class"> |
| <description>It is a bad practice to use the dynamic class Dictionary. Prefer using strongly typed object, or marker interface in order to avoid silent compilation errors while refactoring</description> |
| <priority>1</priority> |
| <example> |
| public class Foo |
| { |
| public var bar : Dictionnary; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.NonStaticConstantFieldRule" |
| message="A constant field should be static ({0})"> |
| <description> |
| </description> |
| <priority>1</priority> |
| <example> |
| public class MyObject { |
| public static const MY_STATIC_CONSTANT : String = "myStaticConstant"; |
| public const MY_NON_STATIC_CONSTANT : String = "myStaticConstant"; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.forbiddentypes.UseGenericTypeRule" |
| message="Use strongly typed objects instead of *"> |
| <description></description> |
| <priority>1</priority> |
| <example> |
| public class Foo |
| { |
| public var bar : *; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.UselessOverridenFunctionRule" |
| message="This method is empty. This should be removed ({0})"> |
| <description>This function is not needed.</description> |
| <priority>3</priority> |
| <example> |
| override protected function createChildren() : void |
| { |
| super.createChildren(); |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.AvoidProtectedFieldInFinalClassRule" |
| message="Protected accessors are useless in a final class. Make it private ({0})"> |
| <priority>3</priority> |
| <example> |
| final public class Foo |
| { |
| protected var bar : int; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.AvoidUsingWithKeyWordRule" |
| message="You should not use the with keyword. It does not help readability"> |
| <priority>3</priority> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.ArrayFieldWithNoArrayElementTypeRule" |
| message="ArrayElementType metadata is not specified for this array-type field ({0})"> |
| <description> |
| </description> |
| <priority>3</priority> |
| <example> |
| public class ArrayVO { |
| public var items:Array; //VIOLATION |
| |
| [ArrayElementType("model.vo.MenuItemVO")] |
| public var menuItems : Array; |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.ClassAndExtensionAreIdenticalRule" |
| message="The extension name is the same as the class name"> |
| <description/> |
| <priority>3</priority> |
| <example> |
| package com.MyCompany |
| { |
| public class SomeClass extends mx.SomeClass // VIOLATION |
| { |
| } |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.ProtectedStaticMethodRule" |
| message="This method ({0}) should be private"> |
| <description/> |
| <priority>3</priority> |
| <example> |
| protected static function foo() : void // VIOLATION |
| { |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.EmptyStatementRule" |
| message="This statement is empty"> |
| <description/> |
| <priority>5</priority> |
| <example> |
| protected function foo() : void |
| { |
| var i : int = 0; |
| |
| ; // VIOLATION |
| } |
| </example> |
| </rule> |
| |
| <rule class="org.apache.flex.pmd.rules.maintanability.ReferenceToVariableBindingFromItsInitializerRule" |
| message="The initializer refers to its variable. Its value will be null."> |
| <priority>1</priority> |
| <example> |
| package |
| { |
| public class Foo |
| { |
| public static const XYZ:String = XYZ; // meant to be "xyz" |
| } |
| } |
| </example> |
| </rule> |
| <rule class="org.apache.flex.pmd.rules.maintanability.AvoidUseOfAsKeywordRule" |
| message="Enforce that as is not used (silently ignores the cast and nulls the property when the type is wrong)"> |
| <priority>5</priority> |
| </rule> |
| </ruleset> |