diff options
author | Godin <mandrikov@gmail.com> | 2010-12-03 10:56:26 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-03 10:56:26 +0000 |
commit | ed8c925b4b41e746288ad63783e09c9ff9c572b9 (patch) | |
tree | f394eab9053501cbdd1a41690bf44bfb84e3f95b | |
parent | a2b82f1adb6c07f2d2a66c30a28970fe52c3ccb3 (diff) | |
download | sonarqube-ed8c925b4b41e746288ad63783e09c9ff9c572b9.tar.gz sonarqube-ed8c925b4b41e746288ad63783e09c9ff9c572b9.zip |
SONAR-2007: Remove IsoCategory from Squid rules
12 files changed, 29 insertions, 45 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/BreakCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/BreakCheck.java index 230936a8f2f..dc3cd9a9b9f 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/BreakCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/BreakCheck.java @@ -20,27 +20,25 @@ package org.sonar.java.ast.check; -import java.util.Arrays; -import java.util.List; - -import org.sonar.check.IsoCategory; +import com.puppycrawl.tools.checkstyle.api.DetailAST; +import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.ast.visitor.AstUtils; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; -import com.puppycrawl.tools.checkstyle.api.DetailAST; -import com.puppycrawl.tools.checkstyle.api.TokenTypes; +import java.util.Arrays; +import java.util.List; @Rule( key = "AvoidBreakOutsideSwitch", name = "Avoid using 'break' branching statement outside a 'switch' statement", - isoCategory = IsoCategory.Maintainability, priority = Priority.MAJOR, description = "<p>The use of the 'break' branching statement increases the essential complexity of the source code and " + "so prevents any refactoring of this source code to replace all well structured control structures with a single statement.</p>" - + "<p>For instance, with the following java program fragment, it's not possible to apply the 'extract method' refactoring pattern :</p>" + + "<p>For instance, with the following java program fragment, it's not possible to apply " + + "the 'extract method' refactoring pattern :</p>" + "<pre>" + "mylabel : for (int i = 0 ; i< 3; i++) {\n" + " for (int j = 0; j < 4 ; j++) {\n" diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/ContinueCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/ContinueCheck.java index e9088b5b384..6249ada3a95 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/ContinueCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/ContinueCheck.java @@ -20,20 +20,18 @@ package org.sonar.java.ast.check; -import java.util.Arrays; -import java.util.List; - -import org.sonar.check.IsoCategory; +import com.puppycrawl.tools.checkstyle.api.DetailAST; +import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceCode; import org.sonar.squid.api.SourceFile; -import com.puppycrawl.tools.checkstyle.api.DetailAST; -import com.puppycrawl.tools.checkstyle.api.TokenTypes; +import java.util.Arrays; +import java.util.List; -@Rule(key = "AvoidContinueStatement", name = "Avoid using 'continue' branching statement", isoCategory = IsoCategory.Maintainability, +@Rule(key = "AvoidContinueStatement", name = "Avoid using 'continue' branching statement", priority = Priority.MAJOR, description = "<p>The use of the 'continue' branching statement increase the essential complexity " + "of the source code and so prevent any refactoring of this source code to replace all well structured control structures " + "with a single statement.</p><p>For instance, in the following java program fragment, it's not possible to apply " diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/UndocumentedApiCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/UndocumentedApiCheck.java index b1dbeb316a2..845a222cf06 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/UndocumentedApiCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/check/UndocumentedApiCheck.java @@ -20,25 +20,19 @@ package org.sonar.java.ast.check; -import java.util.List; - +import com.puppycrawl.tools.checkstyle.api.DetailAST; import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.WildcardPattern; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; import org.sonar.java.PatternUtils; import org.sonar.java.ast.visitor.PublicApiVisitor; -import org.sonar.squid.api.CheckMessage; -import org.sonar.squid.api.SourceClass; -import org.sonar.squid.api.SourceCode; -import org.sonar.squid.api.SourceFile; -import org.sonar.squid.api.SourceMethod; +import org.sonar.squid.api.*; -import com.puppycrawl.tools.checkstyle.api.DetailAST; +import java.util.List; -@Rule(key = "UndocumentedApi", name = "Undocumented API", isoCategory = IsoCategory.Usability, priority = Priority.MAJOR, +@Rule(key = "UndocumentedApi", name = "Undocumented API", priority = Priority.MAJOR, description = "<p>Check that each public class, interface, method and constructor has a Javadoc comment. " + "The following public methods/constructors are not concerned by this rule :</p>" + "<ul><li>Getter / Setter</li>" + "<li>Method with @Override annotation</li>" + "<li>Empty constructor</li></ul>") diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java index 34ab7d466ae..87a1c883579 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/ArchitectureCheck.java @@ -23,7 +23,6 @@ import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.WildcardPattern; import org.sonar.check.Cardinality; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; @@ -38,7 +37,7 @@ import org.sonar.squid.api.SourceMethod; import java.util.Map; @Rule(key = "ArchitecturalConstraint", name = "Architectural constraint", cardinality = Cardinality.MULTIPLE, - isoCategory = IsoCategory.Portability, priority = Priority.MAJOR, + priority = Priority.MAJOR, description = "<p>A source code comply to an architectural model when it fully adheres to a set of architectural constraints. " + "A constraint allows to deny references between classes by pattern.</p>" + "<p>You can for instance use this rule to :</p>" + @@ -99,7 +98,7 @@ public class ArchitectureCheck extends BytecodeCheck { public void visitEdge(AsmEdge edge) { if (asmClass != null && edge != null) { String internalNameTargetClass = edge.getTargetAsmClass().getInternalName(); - if ( !internalNames.containsKey(internalNameTargetClass)) { + if (!internalNames.containsKey(internalNameTargetClass)) { if (WildcardPattern.match(getToPatterns(), internalNameTargetClass)) { int sourceLineNumber = getSourceLineNumber(edge); logMessage(asmClass.getInternalName(), internalNameTargetClass, sourceLineNumber); diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java index 7c6e414ad73..0565ad57495 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/CallToDeprecatedMethodCheck.java @@ -19,7 +19,6 @@ */ package org.sonar.java.bytecode.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; @@ -28,8 +27,8 @@ import org.sonar.java.bytecode.asm.AsmMethod; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; -@Rule(key = "CallToDeprecatedMethod", name = "Avoid use of deprecated method", isoCategory = IsoCategory.Portability, - priority = Priority.MINOR, description = "<p>Once deprecated, a method should no longer be used as it means that " +@Rule(key = "CallToDeprecatedMethod", name = "Avoid use of deprecated method", priority = Priority.MINOR, + description = "<p>Once deprecated, a method should no longer be used as it means that " + "the method might be removed sooner or later.</p>") public class CallToDeprecatedMethodCheck extends BytecodeCheck { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java index dea958ea0d0..63c498df775 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedPrivateMethodCheck.java @@ -19,7 +19,6 @@ */ package org.sonar.java.bytecode.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; @@ -28,7 +27,7 @@ import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; -@Rule(key = "UnusedPrivateMethod", name = "Unused private method", isoCategory = IsoCategory.Maintainability, +@Rule(key = "UnusedPrivateMethod", name = "Unused private method", priority = Priority.MAJOR, description = "<p>Private methods that are never executed are dead code. " + "Dead code means unnecessary, inoperative code that should be removed. " + "This helps in maintenance by decreasing the maintained code size, " + @@ -48,7 +47,7 @@ public class UnusedPrivateMethodCheck extends BytecodeCheck { @Override public void visitMethod(AsmMethod asmMethod) { - if ( !asmMethod.isUsed() && asmMethod.isPrivate() && !asmMethod.isDefaultConstructor() && !SerializableContract.methodMatch(asmMethod)) { + if (!asmMethod.isUsed() && asmMethod.isPrivate() && !asmMethod.isDefaultConstructor() && !SerializableContract.methodMatch(asmMethod)) { CheckMessage message = new CheckMessage(this, "Private method '" + asmMethod.getName() + "(...)' is never used."); SourceMethod sourceMethod = getSourceMethod(asmMethod); if (sourceMethod != null) { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java index b64457d5a96..3974734ab23 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/bytecode/check/UnusedProtectedMethodCheck.java @@ -19,7 +19,6 @@ w * Sonar, open source software quality management tool. */ package org.sonar.java.bytecode.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.java.bytecode.asm.AsmClass; @@ -28,7 +27,7 @@ import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; -@Rule(key = "UnusedProtectedMethod", name = "Unused protected method", isoCategory = IsoCategory.Maintainability, +@Rule(key = "UnusedProtectedMethod", name = "Unused protected method", priority = Priority.MAJOR, description = "<p>Protected methods that are never used by any classes " + "in the same project are strongly suspected to be dead code. " + "Dead code means unnecessary, inoperative code that should be removed. " @@ -48,7 +47,7 @@ public class UnusedProtectedMethodCheck extends BytecodeCheck { @Override public void visitMethod(AsmMethod asmMethod) { - if ( !asmMethod.isUsed() && asmMethod.isProtected() && !asmClass.isAbstract() && !SerializableContract.methodMatch(asmMethod) + if (!asmMethod.isUsed() && asmMethod.isProtected() && !asmClass.isAbstract() && !SerializableContract.methodMatch(asmMethod) && !asmMethod.isInherited()) { CheckMessage message = new CheckMessage(this, "Protected method '" + asmMethod.getName() + "(...)' is never used."); SourceMethod sourceMethod = getSourceMethod(asmMethod); diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/ClassComplexityCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/ClassComplexityCheck.java index de909df1e11..f48f6f1d692 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/ClassComplexityCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/ClassComplexityCheck.java @@ -20,7 +20,6 @@ package org.sonar.java.squid.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; @@ -29,7 +28,7 @@ import org.sonar.squid.api.SourceClass; import org.sonar.squid.api.SourceFile; import org.sonar.squid.measures.Metric; -@Rule(key = "ClassCyclomaticComplexity", name = "Avoid too complex class", isoCategory = IsoCategory.Maintainability, +@Rule(key = "ClassCyclomaticComplexity", name = "Avoid too complex class", priority = Priority.MAJOR, description = "<p>The Cyclomatic Complexity is measured by the number of (&&, ||) operators " + "and (if, while, do, for, ?:, catch, switch, case, return, throw) statements in the body of a class plus one for " + "each constructor, method (but not getter/setter), static initializer, or instance initializer in the class. " diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/DITCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/DITCheck.java index 692a7d05852..347b9b3bdfb 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/DITCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/DITCheck.java @@ -20,7 +20,6 @@ package org.sonar.java.squid.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; @@ -29,7 +28,7 @@ import org.sonar.squid.api.SourceClass; import org.sonar.squid.api.SourceFile; import org.sonar.squid.measures.Metric; -@Rule(key = "MaximumInheritanceDepth", name = "Avoid too deep inheritance tree", isoCategory = IsoCategory.Maintainability, +@Rule(key = "MaximumInheritanceDepth", name = "Avoid too deep inheritance tree", priority = Priority.MAJOR, description = "<p>Inheritance is certainly one of the most valuable concept of object-oriented " + "programming. It's a way to compartmentalize and reuse code by creating collections of attributes and behaviors called " + "classes which can be based on previously created classes. But abusing of this concept by creating a deep inheritance tree " diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/MethodComplexityCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/MethodComplexityCheck.java index 45fa620d7ca..84ffe5f0b95 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/MethodComplexityCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/MethodComplexityCheck.java @@ -20,7 +20,6 @@ package org.sonar.java.squid.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.check.RuleProperty; @@ -29,7 +28,7 @@ import org.sonar.squid.api.SourceFile; import org.sonar.squid.api.SourceMethod; import org.sonar.squid.measures.Metric; -@Rule(key = "MethodCyclomaticComplexity", name = "Avoid too complex method", isoCategory = IsoCategory.Maintainability, +@Rule(key = "MethodCyclomaticComplexity", name = "Avoid too complex method", priority = Priority.MAJOR, description = "<p>The Cyclomatic Complexity is measured by the number of (&&, ||) operators " + "and (if, while, do, for, ?:, catch, switch, case, return, throw) statements in the body of a constructor, " + "method, static initializer, or instance initializer. " diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/NoSonarCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/NoSonarCheck.java index d4f3d53da94..dff3f4dbac3 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/NoSonarCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/NoSonarCheck.java @@ -20,13 +20,12 @@ package org.sonar.java.squid.check; -import org.sonar.check.IsoCategory; import org.sonar.check.Priority; import org.sonar.check.Rule; import org.sonar.squid.api.CheckMessage; import org.sonar.squid.api.SourceFile; -@Rule(key = "NoSonar", name = "Avoid use of //NOSONAR marker", isoCategory = IsoCategory.Reliability, priority = Priority.INFO, +@Rule(key = "NoSonar", name = "Avoid use of //NOSONAR marker", priority = Priority.INFO, description = "<p>Any violation to quality rule can be deactivated with the //NOSONAR marker. This marker is pretty useful to exclude " + "false-positive results but sometimes it can abusively be used to hide real quality flaws.</p>" + "<p>This rule allows to track and/or forbid use of this marker</p>") diff --git a/sonar-check-api/src/main/java/org/sonar/check/Rule.java b/sonar-check-api/src/main/java/org/sonar/check/Rule.java index 5e7d1902104..fe99c2e1c22 100644 --- a/sonar-check-api/src/main/java/org/sonar/check/Rule.java +++ b/sonar-check-api/src/main/java/org/sonar/check/Rule.java @@ -53,6 +53,8 @@ public @interface Rule { /** * Will probably be deprecated and replaced by tags + * + * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007 */ IsoCategory isoCategory() default IsoCategory.NONE; |