From 1d3bedbab5cc4c5051db2b1781d43d1a7b68395f Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 4 May 2011 16:27:41 +0200 Subject: [PATCH] SONAR-2301 ClassComplexityCheck NullPointerException --- .../org/sonar/java/squid/check/ClassComplexityCheck.java | 6 ++++-- .../src/main/java/org/sonar/java/squid/check/DITCheck.java | 6 ++++-- .../org/sonar/java/squid/check/MethodComplexityCheck.java | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) 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 faa95c72a7a..1f360273b95 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 @@ -39,8 +39,10 @@ import org.sonar.squid.measures.Metric; + "and which should be re-factored to be split in several classes.

") public class ClassComplexityCheck extends SquidCheck { - @RuleProperty(description = "Maximum complexity allowed.", defaultValue = "200") - private Integer max; + public static final int DEFAULT_MAX = 200; + + @RuleProperty(description = "Maximum complexity allowed.", defaultValue = "" + DEFAULT_MAX) + private Integer max = DEFAULT_MAX; @Override public void visitClass(SourceClass sourceClass) { 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 b9b13f76f26..9599cd0453b 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 @@ -37,8 +37,10 @@ import org.sonar.squid.measures.Metric; + "'inheritance' when 'composition' would suit better.

") public class DITCheck extends SquidCheck { - @RuleProperty(description = "Maximum depth of the inheritance tree.", defaultValue = "5") - private Integer max; + public static final int DEFAULT_MAX = 5; + + @RuleProperty(description = "Maximum depth of the inheritance tree.", defaultValue = "" + DEFAULT_MAX) + private Integer max = DEFAULT_MAX; @Override public void visitClass(SourceClass sourceClass) { 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 186e859f38f..0cbeb094367 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 @@ -39,8 +39,10 @@ import org.sonar.squid.measures.Metric; + "so the risk of regression increases exponentially.

") public class MethodComplexityCheck extends SquidCheck { - @RuleProperty(description = "Maximum complexity allowed.", defaultValue = "10") - private Integer max; + public static final int DEFAULT_MAX = 10; + + @RuleProperty(description = "Maximum complexity allowed.", defaultValue = "" + DEFAULT_MAX) + private Integer max = DEFAULT_MAX; @Override public void visitMethod(SourceMethod sourceMethod) { -- 2.39.5