aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-19 12:50:03 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-21 17:03:52 +0200
commitae9a6a7ff5a78d8aee765728d8c73f840e7905ff (patch)
tree657c82d1f54dfdf70c6beab3a20cf85b3f552430
parentfd7a43bbe280cf832976f3696776ff5df08de72e (diff)
downloadsonarqube-ae9a6a7ff5a78d8aee765728d8c73f840e7905ff.tar.gz
sonarqube-ae9a6a7ff5a78d8aee765728d8c73f840e7905ff.zip
fix some quality flaws
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/CeQueueModule.java1
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/developer/PersistDevelopersDelegate.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/VisitorsCrawler.java9
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/metric/MetricImpl.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/Project.java9
10 files changed, 29 insertions, 15 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java b/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java
index a6649bd0860..b6dd380211b 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java
@@ -46,6 +46,8 @@ public class Lifecycle {
private static final Map<State, Set<State>> TRANSITIONS = buildTransitions();
+ private State state = INIT;
+
private static Map<State, Set<State>> buildTransitions() {
Map<State, Set<State>> res = new EnumMap<>(State.class);
res.put(INIT, toSet(STARTING));
@@ -68,8 +70,6 @@ public class Lifecycle {
return EnumSet.copyOf(Arrays.asList(states));
}
- private State state = INIT;
-
public State getState() {
return state;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/CeQueueModule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/CeQueueModule.java
index 6a630300745..c2a4506ec8b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/CeQueueModule.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/CeQueueModule.java
@@ -26,7 +26,6 @@ import org.sonar.server.computation.monitoring.CeTasksMBeanImpl;
import org.sonar.server.computation.queue.CeQueueCleaner;
import org.sonar.server.computation.queue.CeQueueInitializer;
import org.sonar.server.computation.queue.InternalCeQueueImpl;
-import org.sonar.server.computation.task.projectanalysis.queue.CleanReportQueueListener;
public class CeQueueModule extends Module {
@Override
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/developer/PersistDevelopersDelegate.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/developer/PersistDevelopersDelegate.java
index de6270051b2..38ee1c5ccc0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/developer/PersistDevelopersDelegate.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/developer/PersistDevelopersDelegate.java
@@ -19,11 +19,16 @@
*/
package org.sonar.server.computation.task.projectanalysis.api.developer;
+import org.sonar.server.computation.task.step.ComputationStep;
+
/**
* This interface is used to delegate the persistence of developers to the Developer Cockpit plugin
*/
public interface PersistDevelopersDelegate {
+ /**
+ * The delegate's implementation of {@link ComputationStep#execute()}.
+ */
void execute();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java
index 4dd54052654..ba4cdf3ac06 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/api/measurecomputer/MeasureComputerContextImpl.java
@@ -190,7 +190,8 @@ public class MeasureComputerContextImpl implements MeasureComputerContext {
? new ComponentImpl.FileAttributesImpl(component.getFileAttributes().getLanguageKey(), component.getFileAttributes().isUnitTest()) : null);
}
- private class ComponentToMeasure implements Function<org.sonar.server.computation.task.projectanalysis.component.Component, Optional<org.sonar.server.computation.task.projectanalysis.measure.Measure>> {
+ private class ComponentToMeasure implements Function<org.sonar.server.computation.task.projectanalysis.component.Component,
+ Optional<org.sonar.server.computation.task.projectanalysis.measure.Measure>> {
private final Metric metric;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/VisitorsCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/VisitorsCrawler.java
index 667ba785790..e94f107eeee 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/VisitorsCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/VisitorsCrawler.java
@@ -155,9 +155,12 @@ public class VisitorsCrawler implements ComponentCrawler {
private static class MatchVisitorMaxDepth implements Predicate<VisitorWrapper> {
private static final Map<Component.Type, MatchVisitorMaxDepth> INSTANCES = buildInstances();
-
private final Component.Type type;
+ private MatchVisitorMaxDepth(Component.Type type) {
+ this.type = requireNonNull(type);
+ }
+
private static Map<Component.Type, MatchVisitorMaxDepth> buildInstances() {
ImmutableMap.Builder<Component.Type, MatchVisitorMaxDepth> builder = ImmutableMap.builder();
for (Component.Type type : Component.Type.values()) {
@@ -166,10 +169,6 @@ public class VisitorsCrawler implements ComponentCrawler {
return builder.build();
}
- private MatchVisitorMaxDepth(Component.Type type) {
- this.type = requireNonNull(type);
- }
-
public static MatchVisitorMaxDepth forComponent(Component component) {
return INSTANCES.get(component.getType());
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/metric/MetricImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/metric/MetricImpl.java
index 31ca5166ee7..bf8ecbe7ad1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/metric/MetricImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/metric/MetricImpl.java
@@ -19,13 +19,14 @@
*/
package org.sonar.server.computation.task.projectanalysis.metric;
-import com.google.common.base.MoreObjects;
import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.sonar.server.computation.task.projectanalysis.measure.Measure;
+import static com.google.common.base.MoreObjects.firstNonNull;
+import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@@ -53,7 +54,7 @@ public final class MetricImpl implements Metric {
this.name = checkNotNull(name);
this.type = checkNotNull(type);
if (type.getValueType() == Measure.ValueType.DOUBLE) {
- this.decimalScale = MoreObjects.firstNonNull(decimalScale, org.sonar.api.measures.Metric.DEFAULT_DECIMAL_SCALE);
+ this.decimalScale = firstNonNull(decimalScale, org.sonar.api.measures.Metric.DEFAULT_DECIMAL_SCALE);
} else {
this.decimalScale = decimalScale;
}
@@ -117,7 +118,7 @@ public final class MetricImpl implements Metric {
@Override
public String toString() {
- return com.google.common.base.MoreObjects.toStringHelper(this)
+ return toStringHelper(this)
.add("id", id)
.add("key", key)
.add("name", name)
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
index ae1af235c1c..341bdc99837 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
@@ -170,7 +170,7 @@ public class ServerPluginRepository implements PluginRepository, Startable {
String pluginKey = info.getKey();
if (blacklistedPluginKeys.contains(pluginKey)) {
LOG.warn("Plugin {} [{}] is blacklisted and is being uninstalled.", info.getName(), pluginKey);
- org.sonar.core.util.FileUtils.deleteQuietly(info.getNonNullJarFile());
+ deleteQuietly(info.getNonNullJarFile());
return;
}
if (FORBIDDEN_COMPATIBLE_PLUGINS.contains(pluginKey)) {
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java b/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java
index b300d047f21..14a6cc53877 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/CleanUsurperRootComponents.java
@@ -119,7 +119,7 @@ public class CleanUsurperRootComponents extends BaseDataChange {
});
}
- private void cleanSnapshotWithIncorrectRoot(Context context) throws SQLException {
+ private static void cleanSnapshotWithIncorrectRoot(Context context) throws SQLException {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select" +
" sn.id" +
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java
index dc26fdd1d26..00b20e211dc 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java
@@ -58,7 +58,7 @@ public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex extends Bas
return true;
}
- public void populateAnalysisUuid(Context context) throws SQLException {
+ public static void populateAnalysisUuid(Context context) throws SQLException {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select("select distinct di.project_snapshot_id, s.uuid from duplications_index di" +
" inner join snapshots s on s.id=di.project_snapshot_id" +
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/Project.java
index 47065821809..16ae114d1a2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/Project.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/Project.java
@@ -23,9 +23,18 @@ package org.sonar.api.ce.posttask;
* @since 5.5
*/
public interface Project {
+ /**
+ * The UUID of the project.
+ */
String getUuid();
+ /**
+ * The key of the project.
+ */
String getKey();
+ /**
+ * The name of the project.
+ */
String getName();
}