aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-squid-java-plugin
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-11-23 20:49:38 +0000
committerGodin <mandrikov@gmail.com>2010-11-23 20:49:38 +0000
commitb22bfd03b71f07eeab42a0ce34e589a42d0920c7 (patch)
treec20b59208b5d0d69283caaa22b998ac74d3d8fd9 /plugins/sonar-squid-java-plugin
parent43814bf35ceb2b9c3a3e6f4fcdea78745acd47a5 (diff)
downloadsonarqube-b22bfd03b71f07eeab42a0ce34e589a42d0920c7.tar.gz
sonarqube-b22bfd03b71f07eeab42a0ce34e589a42d0920c7.zip
Make SquidVisitor interface instead of class
Diffstat (limited to 'plugins/sonar-squid-java-plugin')
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/SquidVisitorNotifier.java3
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/ClassComplexityCheck.java3
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/DITCheck.java3
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/MethodComplexityCheck.java3
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java10
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/visitor/SquidVisitor.java21
6 files changed, 18 insertions, 25 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/SquidVisitorNotifier.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/SquidVisitorNotifier.java
index 740db3c7a7d..98ef164fca4 100644
--- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/SquidVisitorNotifier.java
+++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/SquidVisitorNotifier.java
@@ -18,9 +18,6 @@ public class SquidVisitorNotifier {
}
public void notifyVisitors(SquidIndex indexer) {
- for (SquidVisitor visitor : squidVisitors) {
- visitor.setSquidIndex(indexer);
- }
callVisitClass();
callVisitMethod();
}
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 50892d7fe20..de909df1e11 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
@@ -26,6 +26,7 @@ import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
import org.sonar.squid.api.CheckMessage;
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,
@@ -50,7 +51,7 @@ public class ClassComplexityCheck extends SquidCheck {
+ max + " authorized.");
message.setLine(sourceClass.getStartAtLine());
message.setCost(complexity - max);
- getSourceFile(sourceClass).log(message);
+ sourceClass.getParent(SourceFile.class).log(message);
}
}
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 be0c2bd6f40..3db6a3dcdf4 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
@@ -6,6 +6,7 @@ import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
import org.sonar.squid.api.CheckMessage;
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,
@@ -27,7 +28,7 @@ public class DITCheck extends SquidCheck {
CheckMessage message = new CheckMessage(this, "This class has " + dit + " parents which is greater than " + max + " authorized.");
message.setLine(sourceClass.getStartAtLine());
message.setCost(dit - max);
- getSourceFile(sourceClass).log(message);
+ sourceClass.getParent(SourceFile.class).log(message);
}
}
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 8e527e8a302..7c0810a3872 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
@@ -5,6 +5,7 @@ import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
import org.sonar.squid.api.CheckMessage;
+import org.sonar.squid.api.SourceFile;
import org.sonar.squid.api.SourceMethod;
import org.sonar.squid.measures.Metric;
@@ -30,7 +31,7 @@ public class MethodComplexityCheck extends SquidCheck {
+ max + " authorized.");
message.setLine(sourceMethod.getStartAtLine());
message.setCost(complexity - max);
- getSourceFile(sourceMethod).log(message);
+ sourceMethod.getParent(SourceFile.class).log(message);
}
}
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java
index fe28095de4a..c2fe6ef2572 100644
--- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java
+++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/SquidCheck.java
@@ -2,11 +2,19 @@ package org.sonar.java.squid.check;
import org.sonar.java.squid.visitor.SquidVisitor;
import org.sonar.squid.api.CodeCheck;
+import org.sonar.squid.api.SourceClass;
+import org.sonar.squid.api.SourceMethod;
-public class SquidCheck extends SquidVisitor implements CodeCheck {
+public class SquidCheck implements SquidVisitor, CodeCheck {
public String getKey() {
return getClass().getSimpleName();
}
+ public void visitClass(SourceClass sourceClass) {
+ }
+
+ public void visitMethod(SourceMethod sourceMethod) {
+ }
+
}
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/visitor/SquidVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/visitor/SquidVisitor.java
index f50d4f21c21..802626d59fc 100644
--- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/visitor/SquidVisitor.java
+++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/visitor/SquidVisitor.java
@@ -2,27 +2,12 @@ package org.sonar.java.squid.visitor;
import org.sonar.squid.api.CodeVisitor;
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.indexer.SquidIndex;
-public class SquidVisitor implements CodeVisitor {
+public interface SquidVisitor extends CodeVisitor {
- SquidIndex index;
+ void visitClass(SourceClass sourceClass);
- public void visitClass(SourceClass sourceClass) {
- }
-
- public void visitMethod(SourceMethod sourceMethod) {
- }
-
- protected final SourceFile getSourceFile(SourceCode sourceCode) {
- return sourceCode.getParent(SourceFile.class);
- }
-
- public void setSquidIndex(SquidIndex index) {
- this.index = index;
- }
+ void visitMethod(SourceMethod sourceMethod);
}