aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 16:25:01 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 16:25:08 +0200
commitbdc239fc9ac9c6aa94bc80eab122de7a0fb698ef (patch)
tree5319c5a9da777c247f252566245a4dc9b7a8d5ab /plugins
parent31c56c4337d47b6e0486c8ceb2815c7fa1173dcc (diff)
downloadsonarqube-bdc239fc9ac9c6aa94bc80eab122de7a0fb698ef.tar.gz
sonarqube-bdc239fc9ac9c6aa94bc80eab122de7a0fb698ef.zip
Fix quality flaws
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleaner.java2
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilter.java6
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filter.java6
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filters.java14
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepOneFilter.java6
5 files changed, 17 insertions, 17 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleaner.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleaner.java
index 9d5993cfac1..ade98c3dbaf 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleaner.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DefaultPeriodCleaner.java
@@ -48,7 +48,7 @@ public class DefaultPeriodCleaner implements TaskExtension {
}
public void clean(long projectId) {
- doClean(projectId, new Filters(settings).getFilters());
+ doClean(projectId, new Filters(settings).all());
}
@VisibleForTesting
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilter.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilter.java
index 5a1bcbd381f..18a795e1ee7 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilter.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilter.java
@@ -27,7 +27,7 @@ import org.sonar.core.purge.PurgeableSnapshotDto;
import java.util.Date;
import java.util.List;
-class DeleteAllFilter extends Filter {
+class DeleteAllFilter implements Filter {
private final Date before;
public DeleteAllFilter(Date before) {
@@ -35,7 +35,7 @@ class DeleteAllFilter extends Filter {
}
@Override
- List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
+ public List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
List<PurgeableSnapshotDto> result = Lists.newArrayList();
for (PurgeableSnapshotDto snapshot : history) {
if (snapshot.getDate().before(before)) {
@@ -46,7 +46,7 @@ class DeleteAllFilter extends Filter {
}
@Override
- void log() {
+ public void log() {
LoggerFactory.getLogger(getClass()).info("-> Delete data prior to: " + DateUtils.formatDate(before));
}
}
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filter.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filter.java
index 7bc0b6d6290..4d4419be8c4 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filter.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filter.java
@@ -23,8 +23,8 @@ import org.sonar.core.purge.PurgeableSnapshotDto;
import java.util.List;
-abstract class Filter {
- abstract List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> snapshots);
+interface Filter {
+ List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> snapshots);
- abstract void log();
+ void log();
}
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filters.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filters.java
index 62f7680cc65..c291cd8fec4 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filters.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/Filters.java
@@ -29,7 +29,7 @@ import java.util.Date;
import java.util.List;
class Filters {
- private final List<Filter> filters = Lists.newArrayList();
+ private final List<Filter> all = Lists.newArrayList();
Filters(Settings settings) {
Date dateToStartKeepingOneSnapshotByDay = getDateFromHours(settings, DbCleanerConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY);
@@ -37,14 +37,14 @@ class Filters {
Date dateToStartKeepingOneSnapshotByMonth = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH);
Date dateToStartDeletingAllSnapshots = getDateFromWeeks(settings, DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS);
- filters.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByWeek, dateToStartKeepingOneSnapshotByDay, Calendar.DAY_OF_YEAR, "day"));
- filters.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByMonth, dateToStartKeepingOneSnapshotByWeek, Calendar.WEEK_OF_YEAR, "week"));
- filters.add(new KeepOneFilter(dateToStartDeletingAllSnapshots, dateToStartKeepingOneSnapshotByMonth, Calendar.MONTH, "month"));
- filters.add(new DeleteAllFilter(dateToStartDeletingAllSnapshots));
+ all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByWeek, dateToStartKeepingOneSnapshotByDay, Calendar.DAY_OF_YEAR, "day"));
+ all.add(new KeepOneFilter(dateToStartKeepingOneSnapshotByMonth, dateToStartKeepingOneSnapshotByWeek, Calendar.WEEK_OF_YEAR, "week"));
+ all.add(new KeepOneFilter(dateToStartDeletingAllSnapshots, dateToStartKeepingOneSnapshotByMonth, Calendar.MONTH, "month"));
+ all.add(new DeleteAllFilter(dateToStartDeletingAllSnapshots));
}
- List<Filter> getFilters() {
- return filters;
+ List<Filter> all() {
+ return all;
}
static Date getDateFromWeeks(Settings settings, String propertyKey) {
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepOneFilter.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepOneFilter.java
index 45ad24cf5ff..81249fdd929 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepOneFilter.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/period/KeepOneFilter.java
@@ -28,7 +28,7 @@ import org.sonar.core.purge.PurgeableSnapshotDto;
import java.util.Date;
import java.util.List;
-class KeepOneFilter extends Filter {
+class KeepOneFilter implements Filter {
private final Date start;
private final Date end;
@@ -43,7 +43,7 @@ class KeepOneFilter extends Filter {
}
@Override
- List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
+ public List<PurgeableSnapshotDto> filter(List<PurgeableSnapshotDto> history) {
List<Interval> intervals = Interval.group(history, start, end, dateField);
List<PurgeableSnapshotDto> result = Lists.newArrayList();
for (Interval interval : intervals) {
@@ -54,7 +54,7 @@ class KeepOneFilter extends Filter {
}
@Override
- void log() {
+ public void log() {
LoggerFactory.getLogger(getClass()).info("-> Keep one snapshot per " + label + " between " + DateUtils.formatDate(start) + " and " + DateUtils.formatDate(end));
}