diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
commit | aeadc1f9129274949daaa57738c7c4550bdfbc7b (patch) | |
tree | 08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /plugins/sonar-squid-java-plugin/test-resources/metrics | |
download | sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip |
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'plugins/sonar-squid-java-plugin/test-resources/metrics')
35 files changed, 1109 insertions, 0 deletions
diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/JavaBeanWithApiDoc.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/JavaBeanWithApiDoc.java new file mode 100644 index 00000000000..4a322994300 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/JavaBeanWithApiDoc.java @@ -0,0 +1,31 @@ +package java.bean.test; + +public class JavaBeanWithAPIDoc { + + /** + * Not to count + */ + private String testVar; + + /** + * To count + */ + public String testVar2; + + /** + * This api doc should not be counted not its complexity + * @return + */ + public String getTest() { + return testVar; + } + + /** + * This api doc should be counted + * @return + */ + public String getTest2() { + return "test"; + } + +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/PureJavaBean.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/PureJavaBean.java new file mode 100644 index 00000000000..1af27e2a425 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/accessors/PureJavaBean.java @@ -0,0 +1,95 @@ +package java.bean.test; + +public class PureJavaBean { + + private String testVar; + + public String testVar2; + + String testVar3; + + private boolean booleanTest; + + // OK + public String getTest() { + return testVar; + } + + // OK + public String getTest2() { + return testVar; + } + + // NOT OK + public String getTest3() { + testVar = "test"; + return testVar; + } + + // NOT OK + public String getTest4() { + return testVar + "concat"; + } + + // NOT OK + public void getTest5() { + // do something; + } + + // NOT OK + public String getTest6() { + return "test"; + } + + // NOT OK testVar2 is public + public String getTest7() { + return testVar2; + } + + // OK + public String getTest8() { + // some comments + return testVar; + } + + // OK + public void setTest(String test) { + this.testVar = test; + } + + // NOT OK + public void setTest(String test, String test2) { + this.testVar = test; + } + + // NOT OK + public void setTest() { + this.testVar = test; + } + + // NOT OK + public void setTest2(String test) { + this.testVar = ""; + } + + // NOT OK + public void setTest3(String test) { + this.testVar += test; + } + + // OK + public void setTest4(String test) { + // do something + this.testVar = test; + } + + // NOT OK + public boolean isTest() { + return true; + } + + // OK + public boolean isTest2() { + return booleanTest; + } +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/ComplexBranches.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/ComplexBranches.java new file mode 100644 index 00000000000..ca108445824 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/ComplexBranches.java @@ -0,0 +1,21 @@ +import java.util.ArrayList; + +public class ComplexBranchesTest { + private int n; + + public ComplexBranchesTest(int n) { + this.n = n; + } + + public int getN() { + if (n==1) { + return -1; + } else if (n==2) { + return -2; + } else if (n==3) { + throw new RuntimeException("Error"); + } + return -1; + } + +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/NoBranches.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/NoBranches.java new file mode 100644 index 00000000000..0a897e478c5 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/NoBranches.java @@ -0,0 +1,17 @@ +public class Car { + private int n; + private String s; + + public AClass(int n, String s) { + this.n = n; + this.s = s; + } + + public int getN() { + return n; + } + + public String getS() { + return s; + } +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/SimpleBranches.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/SimpleBranches.java new file mode 100644 index 00000000000..e2bd9a5a875 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/branches/SimpleBranches.java @@ -0,0 +1,52 @@ +import java.util.ArrayList; + +public class Car { + private int n; + private String s; + + public AClass(int n, String s) { + this.n = n; + this.s = s; + } + + public int getN() { + return n; + } + + public String getS() { + return s; + } + + private void simpleIf() { + if (s.equals("road") && n != 1) { + n++; + } + } + + private void ifWithOr() { + if (s.equals("road") || n != 1) { + n++; + } + } + + private void simpleSwitch() { + switch (n) { + case 1: + break; + case 2: + break; + default: + break; + } + } + + private void simpleFor() { + for (int i = 0; i < 4; i++) { + int j = 4; + } + for (String toto : new ArrayList<String>()) { + int k = 0; + } + } + +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AbstractClass.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AbstractClass.java new file mode 100644 index 00000000000..4e1b6cad790 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AbstractClass.java @@ -0,0 +1,7 @@ + +package org.sonar; + +public abstract class AbstractClass { + + //comment +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AnonymousInnerClass.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AnonymousInnerClass.java new file mode 100644 index 00000000000..7d817b69bc7 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/AnonymousInnerClass.java @@ -0,0 +1,20 @@ +import java.util.Comparator; + +class AnonymousInnerClass { + + public void doJob(){ + + Comparator<String> comparator1 = new Comparator<String>() { + public int compare(String o1, String o2) { + return 0; + } + }; + + Comparator<String> comparator2 = new Comparator<String>() { + public int compare(String o1, String o2) { + return 0; + } + }; + } + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/ClassCounterEnum.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/ClassCounterEnum.java new file mode 100644 index 00000000000..d0070da489e --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/ClassCounterEnum.java @@ -0,0 +1,32 @@ +public enum Planet { + MERCURY(3.303e+23, 2.4397e6), VENUS(4.869e+24, 6.0518e6), EARTH(5.976e+24, 6.37814e6), MARS(6.421e+23, 3.3972e6), JUPITER( + 1.9e+27, 7.1492e7), SATURN(5.688e+26, 6.0268e7), URANUS(8.686e+25, 2.5559e7), NEPTUNE(1.024e+26, 2.4746e7), PLUTO( + 1.27e+22, 1.137e6); + + private final double mass; // in kilograms + private final double radius; // in meters + + Planet(double mass, double radius) { + this.mass = mass; + this.radius = radius; + } + + public double mass() { + return mass; + } + + public double radius() { + return radius; + } + + // universal gravitational constant (m3 kg-1 s-2) + public static final double G = 6.67300E-11; + + public double surfaceGravity() { + return G * mass / (radius * radius); + } + + public double surfaceWeight(double otherMass) { + return otherMass * surfaceGravity(); + } +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/InnerClassTests.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/InnerClassTests.java new file mode 100644 index 00000000000..ddc52ade76e --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/InnerClassTests.java @@ -0,0 +1,19 @@ +class InnerClassTests { + + int someInt = 0; + + private void bar() {}; + + private class TestPrivateInnerClass { + + public void foo() {}; + + } + + public class TestPublicInnerClass { + + public void foos() {}; + + } + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Interface.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Interface.java new file mode 100644 index 00000000000..9ca83958581 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Interface.java @@ -0,0 +1,2 @@ +interface Interface { +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Test003.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Test003.java new file mode 100644 index 00000000000..1b1182ebbca --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/classes/Test003.java @@ -0,0 +1,21 @@ +public class Car { + private int n; + private String s; + + public AClass(int n, String s) { + this.n = n; + this.s = s; + } + + public int getN() { + return n; + } + + public String getS() { + return s; + } + + private class Wheel{} +} + +public class AnotherCar{}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/commentedCode/CommentedCode.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/commentedCode/CommentedCode.java new file mode 100644 index 00000000000..7fa37a2e113 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/commentedCode/CommentedCode.java @@ -0,0 +1,25 @@ +public class CommentedCode { + + + public CommentedCode(){ + //This is a comment + //if (true) { + int i = 2; + } + + /** + * No detection of commented code line in Javadoc bloc + * + * public void main(){ + * + * } + */ + public void analyse(){ + /* + for(Visitor visitor : visitors){ + visitor.scan(line); + } + */ + + } +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/complexity/InstanceAndStaticInitBlocks.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/complexity/InstanceAndStaticInitBlocks.java new file mode 100644 index 00000000000..b50a130e193 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/complexity/InstanceAndStaticInitBlocks.java @@ -0,0 +1,10 @@ +public class Car { + + static{ + int j = 4; + } + + { + int i =2; + } +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithComments.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithComments.java new file mode 100644 index 00000000000..6a3f508081f --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithComments.java @@ -0,0 +1,66 @@ +/* + * Header + */ +package test; + +import nothing; +//single comment 1 +/** + * Javadoc 1 + * blablab + * blabla + */ +public class Something { + + public int var = 0; + + /** + * Documented var + */ + public int var2 = 0; + + /** + * Non api documented var + */ + private int var3 = 0; + + /** + * Constructor API doc + * should be included in api doc counter + */ + public Something() { + super(); + /** + * Inner constructor javadoc + * Should not be counted as API doc + */ + } + + public Something(Strng test) { + super(); + } + + /** + * Javadoc 2 + */ + public void sleep(); + + /* + * non javadoc + */ + public void run() { + /** + * Inner javadoc + * + * Should not be counted as API doc + */ + int i = 5; + } + + /** + * Javadoc + */ + private void test() { + } +} +// ncss = 8 diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithCommentsOnLineOfCode.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithCommentsOnLineOfCode.java new file mode 100644 index 00000000000..8f27316339d --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithCommentsOnLineOfCode.java @@ -0,0 +1,14 @@ +package test; + +public class ClassWithCommentsOnLineOfCode { + + public void run() { + int i = 5; // comment on line of code, ncloc should not be impacted + int j = 5; /** test comment + tst 2 comment + **/ + int k = 5; /* another test comment + */ + } + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeader.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeader.java new file mode 100644 index 00000000000..a58d6932246 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeader.java @@ -0,0 +1,32 @@ +/* + * Header + * + * multi lines + */ +package test; + +import nothing; +//single comment 1 +/** + * Javadoc 1 + * blablab + * blabla + */ +public class Something { + public Something() { + super(); + } + + /** + * Javadoc 2 + */ + public void sleep(); + + /* + * non javadoc + */ + public void run() { + int i = 5; + } +} +// ncss = 8 diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndBlankLines.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndBlankLines.java new file mode 100644 index 00000000000..768cb56c232 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndBlankLines.java @@ -0,0 +1,17 @@ +/*
+this header file
+
+has many blank lines
+
+blank lines in comments block
+
+should no be counted
+
+*/
+package test;
+
+public interface ClassWithHeaderAndBlankLines {
+ void reset();
+
+
+}
diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackage.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackage.java new file mode 100644 index 00000000000..f3acca29907 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackage.java @@ -0,0 +1,30 @@ +/* + * Header + * + * but no package + */ +import nothing; +//single comment 1 +/** + * Javadoc 1 + * blablab + * blabla + */ +public class Something { + public Something() { + super(); + } + + /** + * Javadoc 2 + */ + public void sleep(); + + /* + * non javadoc + */ + public void run() { + int i = 5; + } +} +// ncss = 8 diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackageNoImports.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackageNoImports.java new file mode 100644 index 00000000000..cad4070ce9c --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithHeaderAndNoPackageNoImports.java @@ -0,0 +1,23 @@ +/* + * Header + * + * but no package and no import, should be detected as a license header + */ +public class Something { + public Something() { + super(); + } + + /** + * Javadoc 2 + */ + public void sleep(){} + + /* + * non javadoc + */ + public void run() { + int i = 5; + } +} +// ncss = 8 diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithPackageAndJavadocHeader.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithPackageAndJavadocHeader.java new file mode 100644 index 00000000000..a3523c52627 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithPackageAndJavadocHeader.java @@ -0,0 +1,50 @@ +/** + * File header as javadoc + * should be detected as a header + * + */ +package foo; + +/** + * This is a class comment + */ +public class ClassWithPackageAndJavadocHeader { + + public static void doJob1() { + int i = 3; + if (i == 4) { + i++; + } + } + + /** + * + * qsdfqsdf + */ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + //mlkqjdsf + } + } + } + public class Toto{ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + + } + + + + + + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithVars.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithVars.java new file mode 100644 index 00000000000..4135eb29d30 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithVars.java @@ -0,0 +1,59 @@ +/* + * Header + */ +package test; + +import nothing; +//single comment 1 +/** + * Javadoc 1 + */ +public class ClassWithVars { + + /** + * Api doc for this public var + */ + public int publicVar = 0; + + /** + * Not Api doc for this public const, we exclude public final static var to avoid too much noise on pure Constants Classes + */ + public final static int PUBLIC_CONST = 0; + + /** + * Api doc for private var should not be counted as apidoc, but non apidoc + */ + private int pirvateVar = 0; + + + public Something() { + super(); + /** + * Inner constructor javadoc + * Should not be counted as API doc + */ + } + + /** + * Javadoc 2 + */ + public void sleep(); + + /* + * non javadoc + */ + public void run() { + /** + * Inner javadoc + * + * Should not be counted as API doc + */ + int i = 5; + } + + /** + * Javadoc + */ + private void test() { + } +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithoutHeaderAndWithCComment.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithoutHeaderAndWithCComment.java new file mode 100644 index 00000000000..b83822f5b7e --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/ClassWithoutHeaderAndWithCComment.java @@ -0,0 +1,16 @@ +package test; + +import nothing; + +/* + * Javadoc 1 + * blablab + * blabla + */ +public class Something { + + public Something() { + super(); + } + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/Constants.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/Constants.java new file mode 100644 index 00000000000..f52c100b9cb --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/Constants.java @@ -0,0 +1,76 @@ +/* + * $Id: Constants.java 471754 2006-11-06 14:55:09Z husted $ + * + * 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. + */ +package org.apache.struts.chain; + + +/** + * <p>Global constants for the Chain of Responsibility Library.</p> + */ +public final class Constants { + // -------------------------------------------------- Context Attribute Keys + + /** + * <p>The default context attribute under which the ForwardConfig for the + * current request will be stored.</p> + */ + public static final String FORWARD_CONFIG_KEY = "forwardConfig"; + + /** + * <p>The default context attribute under which the include path for the + * current request will be stored.</p> + */ + public static final String INCLUDE_KEY = "include"; + + /** + * <p>The default context attribute under which the Locale for the current + * request will be stored.</p> + */ + public static final String LOCALE_KEY = "locale"; + + /** + * <p>The default context attribute under which the MessageResources for + * the current request will be stored.</p> + */ + public static final String MESSAGE_RESOURCES_KEY = "messageResources"; + + /** + * <p>The default context attribute under which the ModuleConfig for the + * current request will be stored.</p> + */ + public static final String MODULE_CONFIG_KEY = "moduleConfig"; + + /** + * <p>The default context attribute key under which a Boolean is stored, + * indicating the valid state of the current request. If not present, a + * value of Boolean.FALSE should be assumed. + */ + public static final String VALID_KEY = "valid"; + + // --------------------------------------------------------- Other Constants + + /** + * <p>The base part of the context attribute under which a Map containing + * the Action instances associated with this module are stored. This value + * must be suffixed with the module prefix in order to create a unique key + * per module.</p> + */ + public static final String ACTIONS_KEY = "actions"; +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/EmptyConstructor.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/EmptyConstructor.java new file mode 100644 index 00000000000..9f008bbfd8c --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/EmptyConstructor.java @@ -0,0 +1,19 @@ +/* + * Header + */ +package test; + +public class EmptyConstructor { + + + public EmptyConstructor(){ + + } + + public EmptyConstructor(String param){ + + } + + public void doSomething(){ + } +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/InterfaceWithComments.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/InterfaceWithComments.java new file mode 100644 index 00000000000..74db2b709bb --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/InterfaceWithComments.java @@ -0,0 +1,36 @@ +/* + * Header + */ +package test; + +public interface Something { + + /** + * Documented test constant, not part of API docs + */ + public final static int TEST_CONST = "test"; + + /** + * Test javadoc1 + */ + void something(); + + + /** + * Test javadoc2 + */ + public void somethingElse(); + + + /* + * Test comment + * comment line 2 + */ + public void somethingStillElse(); + + void somethingNoComments(); + + public void somethingStillNoComments(); + + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/MethodsWithOverrideAnnotation.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/MethodsWithOverrideAnnotation.java new file mode 100644 index 00000000000..3d1281be0fb --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/javadoc/MethodsWithOverrideAnnotation.java @@ -0,0 +1,23 @@ +/* + * Header + */ +package test; + +public class MethodsWithOverrideAnnotation { + + + @Override + @Deprecated + public void doSomething(){ + + } + + @Override + public void doSomethingElse(){ + + } + + public void doAnotherThing(){ + + } +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test001.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test001.java new file mode 100644 index 00000000000..1b301fce998 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test001.java @@ -0,0 +1,25 @@ +/* + * Header + */ +package test; + +import nothing; +//single comment 1 +/** + * Javadoc 1 + */ +public class Something { + public Something() { + super(); + } + + /** + * Javadoc 2 + */ + public void sleep(); + + public void run() { + int i = 5; + } +} +// ncss = 8 diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test002.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test002.java new file mode 100644 index 00000000000..fec4832be51 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/loc/Test002.java @@ -0,0 +1,19 @@ +import InputNeuron; +import java.util.*; + +public interface Neuron { + + public FloatPoint getWeight(); + public void setWeight(FloatPoint fpWeight); + + public float distanceTo(Neuron nOtherNeuron); + + public void moveTo(InputNeuron inGoalNeuron, int netDistance); + /*schaufelt alle neuen Gewichte zu den alten um*/ + public void move(); + + public void addNeighbor(Neuron neuron); + public void addMetaNeighbor(Neuron neuron); + public Enumeration getNeighbors(); + public Enumeration getMetaNeighbors(); +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithDifferentMethodSignatures.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithDifferentMethodSignatures.java new file mode 100644 index 00000000000..73c1ce0d0e6 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithDifferentMethodSignatures.java @@ -0,0 +1,26 @@ +public abstract class ClassWithDifferentMethodSignatures { + + public ClassWithDifferentMethodSignatures(){} + + public ClassWithDifferentMethodSignatures(List<String> toto){} + + public static void method(); + + public static String method(int a); + + public static double[] method(int a); + + public static void method(String a); + + public static void method(String[][] a); + + public static void method(java.util.ArrayList a); + + public void unusedPrivateMethod(java.util.List<java.lang.String> list, int[] measures); + + public static void method(Map.Entry a); + + public static Squid[] method(int a, double[] b); + + public static java.Squid[] method(Map<Integer, String[]> toto); +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithStaticMethods.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithStaticMethods.java new file mode 100644 index 00000000000..92e33d64f2e --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/ClassWithStaticMethods.java @@ -0,0 +1,30 @@ +public class ClassWithStaticMethods { + + public static void doJob1() { + int i = 3; + if (i == 4) { + i++; + } + } + + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + public class Toto{ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + + } + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/MethodWithAnonymousInnerClass.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/MethodWithAnonymousInnerClass.java new file mode 100644 index 00000000000..a5af21ff2ce --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/methods/MethodWithAnonymousInnerClass.java @@ -0,0 +1,20 @@ +public class MethodWithAnonymousInnerClass { + + public double doJob() { + Job job = new Job(){ + public double doJob(){ + return 0; + } + }; + return job.doJob(); + } + + public double doAnotherJob() { + Job job = new Job(){ + public double doJob(){ + return 0; + } + }; + return job.doJob(); + } +}
\ No newline at end of file diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNcloc.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNcloc.java new file mode 100644 index 00000000000..b9a4ac51bcd --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNcloc.java @@ -0,0 +1,39 @@ +public class ClassWithStaticMethods { + + public static void doJob1() { + int i = 3; + if (i == 4) { + i++; + } + } + + /** + * qsdfqsdf + */ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + //mlkqjdsf + } + } + } + public class Toto{ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + + } + + + + + + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithClassComment.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithClassComment.java new file mode 100644 index 00000000000..74a049aa6eb --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithClassComment.java @@ -0,0 +1,46 @@ +/** + * This is a nice javadoc comments header + * + * And it should ne be included in ncloc + * + */ +public class ClassWithStaticMethodsAndCommentHeader { + + public static void doJob1() { + int i = 3; + if (i == 4) { + i++; + } + } + + /** + * + * qsdfqsdf + */ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + //mlkqjdsf + } + } + } + public class Toto{ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + + } + + + + + + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithHeader.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithHeader.java new file mode 100644 index 00000000000..3e63467b369 --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/ncloc/TestNclocWithHeader.java @@ -0,0 +1,59 @@ +/* + * License test + * header + * + * with blank + * + * lines + */ + +package test; + +/** + * This is a nice comments header + * + * And it should ne be included in ncloc + * + */ +public class ClassWithStaticMethodsAndCommentHeader { + + public static void doJob1() { + int i = 3; + if (i == 4) { + i++; + } + } + + /** + * + * qsdfqsdf + */ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + //mlkqjdsf + // + //another comment + } + } + } + public class Toto{ + public static void doJob2() { + int i = 3; + if (i == 4) { + if (i == 3) { + i--; + } + } + } + + } + + + + + + +} diff --git a/plugins/sonar-squid-java-plugin/test-resources/metrics/statements/NoStatements.java b/plugins/sonar-squid-java-plugin/test-resources/metrics/statements/NoStatements.java new file mode 100644 index 00000000000..22a69f1c21a --- /dev/null +++ b/plugins/sonar-squid-java-plugin/test-resources/metrics/statements/NoStatements.java @@ -0,0 +1,32 @@ +public class Car { + @TestAnnotation + private int n; + private String s; + + public Car(int n, String s) { + this.n = n; + this.s = s; + assert true : "not true"; + } + + public int getN() { + int i =4; + return n; + } + + public String getS() { + return s; + } + + @SuppressWarnings("deprecation") + public void simpleIf(@TestAnnotation String var){ + @TestAnnotation + int varDecl = -1; + if( s.equals("toto") ){ + n = 4; + } else { + n = 3; + } + assert true : "not true"; + } +}
\ No newline at end of file |