aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-04 17:24:22 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-04 17:24:22 +0000
commit14271770a03173f464498e1b6ebf527799c7b75e (patch)
treec99c5f0c99efd5a1a9266854aa709f4955c7762d
parent9934361a0754eff905e06515618f47cc51dd699e (diff)
downloadsonarqube-14271770a03173f464498e1b6ebf527799c7b75e.tar.gz
sonarqube-14271770a03173f464498e1b6ebf527799c7b75e.zip
some method renaming + improve code Q
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java2
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshot.java6
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfiguration.java16
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java4
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java2
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java2
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java2
7 files changed, 21 insertions, 13 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
index 7a134d83bd3..ca9a844f791 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewViolationsDecorator.java
@@ -53,7 +53,7 @@ public class NewViolationsDecorator implements Decorator {
public void decorate(Resource resource, DecoratorContext context) {
Measure measure = new Measure(CoreMetrics.NEW_VIOLATIONS);
- for (PastSnapshot variationSnapshot : timeMachineConfiguration.getVariationSnapshots()) {
+ for (PastSnapshot variationSnapshot : timeMachineConfiguration.getProjectPastSnapshots()) {
Date date = variationSnapshot.getDate();
double value = countViolationsAfterDate(context.getViolations(), date) + sumChildren(context, variationSnapshot.getIndex());
measure.setVariation(variationSnapshot.getIndex(), value);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshot.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshot.java
index 3da2517f606..1193c4294dd 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshot.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshot.java
@@ -19,6 +19,7 @@
*/
package org.sonar.plugins.core.timemachine;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.sonar.api.database.model.Snapshot;
import java.util.Date;
@@ -59,4 +60,9 @@ public final class PastSnapshot {
this.modeParameter = s;
return this;
}
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfiguration.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfiguration.java
index 1f0894fd085..d658ed9aa7e 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfiguration.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfiguration.java
@@ -32,7 +32,7 @@ public class TimeMachineConfiguration implements BatchExtension {
private static final int NUMBER_OF_VARIATION_SNAPSHOTS = 3;
private final Configuration configuration;
- private List<PastSnapshot> variationSnapshots;
+ private List<PastSnapshot> projectPastSnapshots;
public TimeMachineConfiguration(Configuration configuration, PastSnapshotFinder variationSnapshotFinder) {
this.configuration = configuration;
@@ -40,11 +40,11 @@ public class TimeMachineConfiguration implements BatchExtension {
}
private void initVariationSnapshots(PastSnapshotFinder variationSnapshotFinder) {
- variationSnapshots = Lists.newLinkedList();
+ projectPastSnapshots = Lists.newLinkedList();
for (int index = 1; index <= NUMBER_OF_VARIATION_SNAPSHOTS; index++) {
PastSnapshot variationSnapshot = variationSnapshotFinder.find(configuration, index);
if (variationSnapshot != null) {
- variationSnapshots.add(variationSnapshot);
+ projectPastSnapshots.add(variationSnapshot);
}
}
}
@@ -52,9 +52,9 @@ public class TimeMachineConfiguration implements BatchExtension {
/**
* for unit tests
*/
- TimeMachineConfiguration(Configuration configuration, List<PastSnapshot> variationSnapshots) {
+ TimeMachineConfiguration(Configuration configuration, List<PastSnapshot> projectPastSnapshots) {
this.configuration = configuration;
- this.variationSnapshots = variationSnapshots;
+ this.projectPastSnapshots = projectPastSnapshots;
}
/**
@@ -62,7 +62,7 @@ public class TimeMachineConfiguration implements BatchExtension {
*/
TimeMachineConfiguration(Configuration configuration) {
this.configuration = configuration;
- this.variationSnapshots = Collections.emptyList();
+ this.projectPastSnapshots = Collections.emptyList();
}
@@ -74,7 +74,7 @@ public class TimeMachineConfiguration implements BatchExtension {
return configuration.getInt(CoreProperties.CORE_TENDENCY_DEPTH_PROPERTY, CoreProperties.CORE_TENDENCY_DEPTH_DEFAULT_VALUE);
}
- public List<PastSnapshot> getVariationSnapshots() {
- return variationSnapshots;
+ public List<PastSnapshot> getProjectPastSnapshots() {
+ return projectPastSnapshots;
}
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
index b587d2707c5..3fc43b9a784 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
@@ -38,7 +38,7 @@ public final class TimeMachineConfigurationPersister implements BatchExtension {
}
public void start() {
- List<PastSnapshot> variationSnapshots = configuration.getVariationSnapshots();
+ List<PastSnapshot> variationSnapshots = configuration.getProjectPastSnapshots();
for (PastSnapshot variationSnapshot : variationSnapshots) {
switch (variationSnapshot.getIndex()) {
case 1:
@@ -53,6 +53,8 @@ public final class TimeMachineConfigurationPersister implements BatchExtension {
projectSnapshot.setVarMode3(variationSnapshot.getConfigurationMode());
projectSnapshot.setVarLabel3(variationSnapshot.getConfigurationModeParameter());
break;
+ default:
+ throw new IndexOutOfBoundsException("Index of variation configuration is out of range: " + variationSnapshot);
}
session.save(projectSnapshot);
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
index 12635f88ff5..4672fdbc10f 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
@@ -43,7 +43,7 @@ public class VariationDecorator implements Decorator {
private PastMeasuresLoader pastMeasuresLoader;
public VariationDecorator(PastMeasuresLoader pastMeasuresLoader, TimeMachineConfiguration configuration) {
- this(pastMeasuresLoader, configuration.getVariationSnapshots());
+ this(pastMeasuresLoader, configuration.getProjectPastSnapshots());
}
VariationDecorator(PastMeasuresLoader pastMeasuresLoader, List<PastSnapshot> projectPastSnapshots) {
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java
index 900f8c45711..5d08a57f163 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java
@@ -39,7 +39,7 @@ public class TimeMachineConfigurationPersisterTest extends AbstractDbUnitTestCas
.setConfigurationModeParameter("30");
PastSnapshot vs3 = new PastSnapshot(3, "version", getSession().getSingleResult(Snapshot.class, "id", 300))
.setConfigurationModeParameter("1.2.3");
- when(conf.getVariationSnapshots()).thenReturn(Arrays.asList(vs1, vs3));
+ when(conf.getProjectPastSnapshots()).thenReturn(Arrays.asList(vs1, vs3));
Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1000);
TimeMachineConfigurationPersister persister = new TimeMachineConfigurationPersister(conf, projectSnapshot, getSession());
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java
index 4a3d89ba489..67b8f7ea1b0 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationTest.java
@@ -56,7 +56,7 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase {
verify(snapshotReferenceFinder).find(conf, 2);
verify(snapshotReferenceFinder).find(conf, 3);
- assertThat(timeMachineConfiguration.getVariationSnapshots().size(), is(2));
+ assertThat(timeMachineConfiguration.getProjectPastSnapshots().size(), is(2));
}
n value='backport/48307/stable29'>backport/48307/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/files/l10n/mr.json
blob: ef5fc5867559edeb7403fc6b15799db74f55eff6 (plain)
1
2
3
4
5
6
7