aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/main')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java26
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java24
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DefaultDecoratorContext.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java5
6 files changed, 32 insertions, 39 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
index dfd3a7c009c..ee49c44441a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
@@ -22,6 +22,15 @@ package org.sonar.batch.bootstrap;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import javax.annotation.Nullable;
import org.apache.commons.lang.ClassUtils;
import org.sonar.api.batch.CheckProject;
import org.sonar.api.batch.DependedUpon;
@@ -31,7 +40,6 @@ import org.sonar.api.batch.postjob.PostJob;
import org.sonar.api.batch.postjob.PostJobContext;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.AnnotationUtils;
import org.sonar.api.utils.dag.DirectAcyclicGraph;
@@ -40,17 +48,7 @@ import org.sonar.batch.postjob.PostJobWrapper;
import org.sonar.batch.sensor.DefaultSensorContext;
import org.sonar.batch.sensor.SensorOptimizer;
import org.sonar.batch.sensor.SensorWrapper;
-
-import javax.annotation.Nullable;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
+import org.sonar.core.platform.ComponentContainer;
/**
* @since 2.6
@@ -245,7 +243,7 @@ public class BatchExtensionDictionnary {
}
}
- private void checkAnnotatedMethod(Method method) {
+ private static void checkAnnotatedMethod(Method method) {
if (!Modifier.isPublic(method.getModifiers())) {
throw new IllegalStateException("Annotated method must be public:" + method);
}
@@ -254,7 +252,7 @@ public class BatchExtensionDictionnary {
}
}
- private boolean shouldKeep(Class type, Object extension, @Nullable Project project, @Nullable ExtensionMatcher matcher) {
+ private static boolean shouldKeep(Class type, Object extension, @Nullable Project project, @Nullable ExtensionMatcher matcher) {
boolean keep = (ClassUtils.isAssignable(extension.getClass(), type)
|| (org.sonar.api.batch.Sensor.class.equals(type) && ClassUtils.isAssignable(extension.getClass(), Sensor.class)))
&& (matcher == null || matcher.accept(extension));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
index c0574deddd6..4f40634966f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
@@ -19,7 +19,6 @@
*/
package org.sonar.batch.bootstrap;
-import org.sonar.home.cache.PersistentCache;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
@@ -29,17 +28,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.utils.HttpDownloader;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
-import org.sonar.core.util.DefaultHttpDownloader;
-
-import javax.annotation.Nullable;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@@ -50,6 +38,16 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
+import javax.annotation.Nullable;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.utils.HttpDownloader;
+import org.sonar.batch.bootstrapper.EnvironmentInformation;
+import org.sonar.core.util.DefaultHttpDownloader;
+import org.sonar.home.cache.PersistentCache;
/**
* Replace the deprecated org.sonar.batch.ServerMetadata
@@ -180,7 +178,7 @@ public class ServerClient {
return new IllegalStateException(String.format("Fail to execute request [code=%s, url=%s]", he.getResponseCode(), he.getUri()), he);
}
- private String tryParseAsJsonError(String responseContent) {
+ private static String tryParseAsJsonError(String responseContent) {
try {
JsonParser parser = new JsonParser();
JsonObject obj = parser.parse(responseContent).getAsJsonObject();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
index 8cd0656e310..0a33396354a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
@@ -19,6 +19,8 @@
*/
package org.sonar.batch.deprecated;
+import java.io.Serializable;
+import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.AnalysisMode;
@@ -44,9 +46,6 @@ import org.sonar.api.utils.SonarException;
import org.sonar.batch.sensor.DefaultSensorContext;
import org.sonar.batch.sensor.coverage.CoverageExclusions;
-import java.io.Serializable;
-import java.util.Collection;
-
public class DeprecatedSensorContext extends DefaultSensorContext implements SensorContext {
private static final Logger LOG = LoggerFactory.getLogger(DeprecatedSensorContext.class);
@@ -82,7 +81,7 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen
return true;
}
- private void logWarning() {
+ private static void logWarning() {
if (LOG.isDebugEnabled()) {
LOG.debug("Plugins are no more responsible for indexing physical resources like directories and files. This is now handled by the platform.", new SonarException(
"Plugin should not index physical resources"));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DefaultDecoratorContext.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DefaultDecoratorContext.java
index 673357db494..a8e06058ecf 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DefaultDecoratorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/DefaultDecoratorContext.java
@@ -22,6 +22,8 @@ package org.sonar.batch.deprecated.decorator;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.List;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.SonarIndex;
import org.sonar.api.design.Dependency;
@@ -38,9 +40,6 @@ import org.sonar.api.utils.SonarException;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.sensor.coverage.CoverageExclusions;
-import java.util.Collection;
-import java.util.List;
-
public class DefaultDecoratorContext implements DecoratorContext {
private static final String SAVE_MEASURE_METHOD = "saveMeasure";
@@ -111,7 +110,7 @@ public class DefaultDecoratorContext implements DecoratorContext {
}
private <M> Collection<Measure> getMeasuresOfASingleMetric(MeasuresFilters.MetricFilter<M> filter) {
- String metricKey = ((MeasuresFilters.MetricFilter<M>) filter).filterOnMetricKey();
+ String metricKey = filter.filterOnMetricKey();
return measuresByMetric.get(metricKey);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
index 72f150aa9c5..17b3756fccc 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java
@@ -70,7 +70,7 @@ public class ModuleProfiling extends AbstractTimeProfiling {
categories.putAll(profilingPerBatchStep);
for (Map.Entry<Object, AbstractTimeProfiling> batchStep : categories.entrySet()) {
- props.setProperty(batchStep.getKey().toString(), "" + batchStep.getValue().totalTime());
+ props.setProperty(batchStep.getKey().toString(), Long.toString(batchStep.getValue().totalTime()));
}
for (Map.Entry<Object, AbstractTimeProfiling> batchStep : sortByDescendingTotalTime(categories).entrySet()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
index 15b16d02b49..b13767eefca 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java
@@ -19,12 +19,11 @@
*/
package org.sonar.batch.profiling;
-import org.sonar.api.utils.System2;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import org.sonar.api.utils.System2;
public class PhaseProfiling extends AbstractTimeProfiling {
@@ -76,7 +75,7 @@ public class PhaseProfiling extends AbstractTimeProfiling {
public void dump(Properties props) {
double percent = this.totalTime() / 100.0;
for (ItemProfiling itemProfiling : profilingPerItem.values()) {
- props.setProperty(itemProfiling.itemName(), "" + itemProfiling.totalTime());
+ props.setProperty(itemProfiling.itemName(), Long.toString(itemProfiling.totalTime()));
}
for (ItemProfiling itemProfiling : truncate(sortByDescendingTotalTime(profilingPerItem).values())) {
println(" o " + itemProfiling.itemName() + ": ", percent, itemProfiling);