aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-03-27 23:43:19 +0200
committersimonbrandhof <simon.brandhof@gmail.com>2011-03-27 23:43:19 +0200
commitd4ae5228bb668e65baa644b52d41286d5f3d55cd (patch)
tree8b3f18401fade28db31c1b9364e2f4ebad2b017d /plugins
parent2b560c35ab24a4f7db27d7e180a64e830b9a56a1 (diff)
downloadsonarqube-d4ae5228bb668e65baa644b52d41286d5f3d55cd.tar.gz
sonarqube-d4ae5228bb668e65baa644b52d41286d5f3d55cd.zip
Fix coding violations
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java8
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java5
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java1
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java32
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java17
-rw-r--r--plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java5
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java4
7 files changed, 34 insertions, 38 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 8363f5b9297..236581dc351 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -113,7 +113,9 @@ import java.util.List;
@Property(
key = "sonar.timemachine.period1",
name = "Period 1",
- description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
+ description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " +
+ "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
+ "compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
project = false,
global = true,
defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1
@@ -137,7 +139,9 @@ import java.util.List;
@Property(
key = "sonar.timemachine.period4",
name = "Period 4",
- description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : <ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
+ description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : " +
+ "<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " +
+ "for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
project = true,
global = false,
defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java
index 0944f8dabcd..1ea98d87a15 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CoverageDecorator.java
@@ -20,7 +20,6 @@
package org.sonar.plugins.core.sensors;
import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.MeasureUtils;
@@ -28,7 +27,6 @@ import org.sonar.api.measures.Metric;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
public final class CoverageDecorator extends AbstractCoverageDecorator {
@@ -61,7 +59,6 @@ public final class CoverageDecorator extends AbstractCoverageDecorator {
}
-
@Override
protected Metric getGeneratedMetricForNewCode() {
return CoreMetrics.NEW_COVERAGE;
@@ -70,7 +67,7 @@ public final class CoverageDecorator extends AbstractCoverageDecorator {
@Override
protected Long countElementsForNewCode(DecoratorContext context, int periodIndex) {
Long newLinesToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_LINES_TO_COVER), periodIndex);
- if (newLinesToCover!=null) {
+ if (newLinesToCover != null) {
long newConditionsToCover = MeasureUtils.getVariationAsLong(context.getMeasure(CoreMetrics.NEW_CONDITIONS_TO_COVER), periodIndex, 0L);
return newLinesToCover + newConditionsToCover;
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
index e68ae61ce77..0758fdeb57d 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java
@@ -30,7 +30,6 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
import org.sonar.api.resources.Scopes;
import org.sonar.batch.components.TimeMachineConfiguration;
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
index 3c64cd47ff4..4950b178270 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
@@ -19,11 +19,14 @@
*/
package org.sonar.plugins.cpd;
-import org.sonar.api.*;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Plugin;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
import org.sonar.plugins.cpd.decorators.DuplicationDensityDecorator;
import org.sonar.plugins.cpd.decorators.SumDuplicationsDecorator;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@Properties({
@@ -36,14 +39,14 @@ import java.util.List;
module = true,
global = true),
@Property(
- key = CoreProperties.CPD_IGNORE_LITERALS_PROPERTY,
- defaultValue = CoreProperties.CPD_IGNORE_LITERALS_DEFAULT_VALUE + "",
- name = "Ignore literals",
- description = "if true, CPD ignores literal value differences when evaluating a duplicate block. " +
- "This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
- project = true,
- module = true,
- global = true),
+ key = CoreProperties.CPD_IGNORE_LITERALS_PROPERTY,
+ defaultValue = CoreProperties.CPD_IGNORE_LITERALS_DEFAULT_VALUE + "",
+ name = "Ignore literals",
+ description = "if true, CPD ignores literal value differences when evaluating a duplicate block. " +
+ "This means that foo=\"first string\"; and foo=\"second string\"; will be seen as equivalent.",
+ project = true,
+ module = true,
+ global = true),
@Property(
key = CoreProperties.CPD_IGNORE_IDENTIFIERS_PROPERTY,
defaultValue = CoreProperties.CPD_IGNORE_IDENTIFIERS_DEFAULT_VALUE + "",
@@ -75,12 +78,7 @@ public class CpdPlugin implements Plugin {
return "Find duplicated source code within project.";
}
- public List<Class<? extends Extension>> getExtensions() {
- List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
- list.add(CpdSensor.class);
- list.add(SumDuplicationsDecorator.class);
- list.add(DuplicationDensityDecorator.class);
- list.add(JavaCpdMapping.class);
- return list;
+ public List getExtensions() {
+ return Arrays.asList(CpdSensor.class, SumDuplicationsDecorator.class, DuplicationDensityDecorator.class, JavaCpdMapping.class);
}
} \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
index 29eb7551453..994b9e46f46 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
@@ -19,27 +19,25 @@
*/
package org.sonar.plugins.findbugs;
+import org.sonar.api.*;
+
import java.util.ArrayList;
import java.util.List;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.Extension;
-import org.sonar.api.Plugin;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
-
@Properties({
@Property(
key = CoreProperties.FINDBUGS_EFFORT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_EFFORT_DEFAULT_VALUE,
name = "Effort",
- description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases memory consumption.",
+ description = "Effort of the bug finders. Valid values are Min, Default and Max. Setting 'Max' increases precision but also increases " +
+ "memory consumption.",
project = true, module = true, global = true),
@Property(
key = CoreProperties.FINDBUGS_TIMEOUT_PROPERTY,
defaultValue = CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE + "",
name = "Timeout",
- description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. The default is 600,000 milliseconds, which is ten minutes.",
+ description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. " +
+ "The default is 600,000 milliseconds, which is ten minutes.",
project = true, module = true, global = true) })
public class FindbugsPlugin implements Plugin {
@@ -52,7 +50,8 @@ public class FindbugsPlugin implements Plugin {
}
public String getDescription() {
- return "FindBugs is a program that uses static analysis to look for bugs in Java code. It can detect a variety of common coding mistakes, including thread synchronization problems, misuse of API methods... You can find more by going to the <a href='http://findbugs.sourceforge.net'>Findbugs web site</a>.";
+ return "FindBugs is a program that uses static analysis to look for bugs in Java code. It can detect a variety of common coding mistakes, " +
+ "including thread synchronization problems, misuse of API methods... You can find more by going to the <a href='http://findbugs.sourceforge.net'>Findbugs web site</a>.";
}
public List<Class<? extends Extension>> getExtensions() {
diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java
index e1552a340f7..e60b2b06748 100644
--- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java
+++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.BatchExtension;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Project;
+import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.TimeProfiler;
import org.sonar.java.api.JavaUtils;
@@ -122,7 +123,7 @@ public class PmdExecutor implements BatchExtension {
return stream;
} catch (FileNotFoundException e) {
- throw new RuntimeException("The PMD ruleset can not be found: " + rulesetPath);
+ throw new SonarException("The PMD ruleset can not be found: " + rulesetPath, e);
}
}
@@ -159,7 +160,7 @@ public class PmdExecutor implements BatchExtension {
LOG.info("Java version: " + javaVersion);
pmd.setJavaVersion(sourceType);
} else {
- throw new RuntimeException("Unsupported Java version for PMD: " + javaVersion);
+ throw new SonarException("Unsupported Java version for PMD: " + javaVersion);
}
}
}
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java
index 8a103e593ea..f09b08e5a5d 100644
--- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java
+++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/ChidamberKemererBridge.java
@@ -21,8 +21,6 @@ package org.sonar.plugins.squid.bridges;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.resources.Resource;
-import org.sonar.java.api.JavaClass;
-import org.sonar.squid.api.SourceClass;
import org.sonar.squid.api.SourceFile;
import org.sonar.squid.measures.Metric;
@@ -39,7 +37,7 @@ public class ChidamberKemererBridge extends Bridge {
context.saveMeasure(sonarFile, CoreMetrics.RFC, squidFile.getDouble(Metric.RFC));
double lcom4 = squidFile.getDouble(Metric.LCOM4);
- if (lcom4>0.0) {
+ if (lcom4 > 0.0) {
context.saveMeasure(sonarFile, CoreMetrics.LCOM4, lcom4);
}
}