aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-squid-java-plugin/test-resources
diff options
context:
space:
mode:
authorDinesh Bolkensteyn <dinesh@dinsoft.net>2011-10-26 20:38:50 +0200
committerDinesh Bolkensteyn <dinesh@dinsoft.net>2011-10-26 21:41:14 +0200
commit2b65589c5e5549ac2bd7db4e858feb66bd6dbab4 (patch)
tree0828d5ff3c251d4191dc4e95eb0f8d0aa7501585 /plugins/sonar-squid-java-plugin/test-resources
parent0cbd0265b311210fb43ac6ff044005d5ca75d8ce (diff)
downloadsonarqube-2b65589c5e5549ac2bd7db4e858feb66bd6dbab4.tar.gz
sonarqube-2b65589c5e5549ac2bd7db4e858feb66bd6dbab4.zip
SONAR-2941 Exclude isolated methods from LCOM4 computation
Diffstat (limited to 'plugins/sonar-squid-java-plugin/test-resources')
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/ExclusionOfFieldNamesFromLcom4Calculation.classbin890 -> 1182 bytes
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4Exclusions.classbin695 -> 859 bytes
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithIsolatedMethods.classbin0 -> 573 bytes
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithWorkers.classbin0 -> 991 bytes
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/ExclusionOfFieldNamesFromLcom4Calculation.java21
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4Exclusions.java11
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithIsolatedMethods.java11
-rw-r--r--plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithWorkers.java27
8 files changed, 64 insertions, 6 deletions
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/ExclusionOfFieldNamesFromLcom4Calculation.class b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/ExclusionOfFieldNamesFromLcom4Calculation.class
index f779fe90360..bfa2977a941 100644
--- a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/ExclusionOfFieldNamesFromLcom4Calculation.class
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/ExclusionOfFieldNamesFromLcom4Calculation.class
Binary files differ
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4Exclusions.class b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4Exclusions.class
index 1c3b11f2568..53c65ec0981 100644
--- a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4Exclusions.class
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4Exclusions.class
Binary files differ
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithIsolatedMethods.class b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithIsolatedMethods.class
new file mode 100644
index 00000000000..0e414fd437a
--- /dev/null
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithIsolatedMethods.class
Binary files differ
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithWorkers.class b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithWorkers.class
new file mode 100644
index 00000000000..7ab3f59ce13
--- /dev/null
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/bin/LCOM4WithWorkers.class
Binary files differ
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/ExclusionOfFieldNamesFromLcom4Calculation.java b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/ExclusionOfFieldNamesFromLcom4Calculation.java
index 8e0490f3ea2..760389da3bb 100644
--- a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/ExclusionOfFieldNamesFromLcom4Calculation.java
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/ExclusionOfFieldNamesFromLcom4Calculation.java
@@ -5,13 +5,28 @@ import java.util.logging.Logger;
public class ExclusionOfFieldNamesFromLcom4Calculation {
- private static final Logger LOG =Logger.getLogger("log");
+ private final Logger LOG = Logger.getLogger("log");
+ private boolean killAccessorBlockA;
+ private boolean killAccessorBlockB;
- public void firstMethod(){
+ public void firstMethodBlockA(){
+ secondMethodBlockA();
LOG.log(Level.INFO, "a message");
}
- public void secondMethod(){
+ public void secondMethodBlockA(){
LOG.log(Level.INFO, "a message");
+ killAccessorBlockA = true;
}
+
+ public void firstMethodBlockB(){
+ secondMethodBlockB();
+ LOG.log(Level.INFO, "a message");
+ }
+
+ public void secondMethodBlockB(){
+ LOG.log(Level.INFO, "a message");
+ killAccessorBlockB = true;
+ }
+
}
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4Exclusions.java b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4Exclusions.java
index aa1f6bffa26..25f4e8ed464 100644
--- a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4Exclusions.java
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4Exclusions.java
@@ -2,7 +2,8 @@
public abstract class LCOM4Exclusions implements Runnable {
- public static String field;
+ public static String field1;
+ public static String field2;
public LCOM4Exclusions(){}
@@ -13,10 +14,14 @@ public abstract class LCOM4Exclusions implements Runnable {
public abstract void doAbstractWork();
public void run(){
- int i =0;
+ run2();
+ }
+
+ public void run2(){
+ run();
}
public boolean equals(Object object){
- return false;
+ return (field1 == null) ? false : field1.equals(field2);
}
}
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithIsolatedMethods.java b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithIsolatedMethods.java
new file mode 100644
index 00000000000..6e310f01703
--- /dev/null
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithIsolatedMethods.java
@@ -0,0 +1,11 @@
+public class LCOM4WithIsolatedMethods {
+
+ public void myUnsupportedMethod(){
+ throw new UnsupportedOperationException("...");
+ }
+
+ public String myConstantValue() {
+ return "...";
+ }
+
+}
diff --git a/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithWorkers.java b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithWorkers.java
new file mode 100644
index 00000000000..a4f966e0ed3
--- /dev/null
+++ b/plugins/sonar-squid-java-plugin/test-resources/bytecode/lcom4/src/LCOM4WithWorkers.java
@@ -0,0 +1,27 @@
+public class LCOM4WithWorkers {
+ private String field = "toto";
+
+ public String getField() {
+ return field;
+ }
+
+ public void doSomething() {
+ task1();
+ field = "tata";
+ }
+
+ public void doSomethingElse() {
+ task2();
+ getField();
+ }
+
+ public void task1() {
+ System.out.println("Hello 1");
+ System.out.println("Hello 2");
+ }
+
+ public void task2() {
+ System.out.println("Hello 1");
+ System.out.println("Hello 2");
+ }
+}