diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-29 15:53:56 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-29 19:01:12 +0200 |
commit | 501289ca85e1c8dd21d5e0ba5f457b40ee62f5ef (patch) | |
tree | ba5b06c4357edb58ec3f248c6fa12324c1ec71ca | |
parent | fcf0d15e049e9c6e647fae628dc0e2bc17d078b6 (diff) | |
download | sonarqube-501289ca85e1c8dd21d5e0ba5f457b40ee62f5ef.tar.gz sonarqube-501289ca85e1c8dd21d5e0ba5f457b40ee62f5ef.zip |
Quality flaws
- do not declare multiple variables on same line
- fix imports
107 files changed, 655 insertions, 329 deletions
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java index 3edd35324a9..a144d7aad1d 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java @@ -142,7 +142,8 @@ public class MonitorTest { @Test public void start_then_stop_sequence_of_commands() throws Exception { monitor = newDefaultMonitor(); - HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); + HttpProcessClient p1 = new HttpProcessClient("p1"); + HttpProcessClient p2 = new HttpProcessClient("p2"); monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); // start p2 when p1 is fully started (ready) @@ -163,7 +164,8 @@ public class MonitorTest { @Test public void stop_all_processes_if_monitor_shutdowns() throws Exception { monitor = newDefaultMonitor(); - HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); + HttpProcessClient p1 = new HttpProcessClient("p1"); + HttpProcessClient p2 = new HttpProcessClient("p2"); monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); assertThat(p1.isReady()).isTrue(); assertThat(p2.isReady()).isTrue(); @@ -179,7 +181,8 @@ public class MonitorTest { @Test public void stop_all_processes_if_one_shutdowns() throws Exception { monitor = newDefaultMonitor(); - HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); + HttpProcessClient p1 = new HttpProcessClient("p1"); + HttpProcessClient p2 = new HttpProcessClient("p2"); monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); assertThat(p1.isReady()).isTrue(); assertThat(p2.isReady()).isTrue(); @@ -197,7 +200,8 @@ public class MonitorTest { @Test public void stop_all_processes_if_one_fails_to_start() throws Exception { monitor = newDefaultMonitor(); - HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2", -1); + HttpProcessClient p1 = new HttpProcessClient("p1"); + HttpProcessClient p2 = new HttpProcessClient("p2", -1); try { monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); fail(); diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java b/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java index b029604a56a..5af66245b72 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java @@ -71,7 +71,9 @@ class SearchSettings { private void configureFileSystem(ImmutableSettings.Builder builder) { File homeDir = props.nonNullValueAsFile(ProcessProperties.PATH_HOME); - File dataDir, workDir, logDir; + File dataDir; + File workDir; + File logDir; // data dir String dataPath = props.value(ProcessProperties.PATH_DATA); diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java index 295eb86b94a..c7ee21325ad 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java @@ -86,7 +86,9 @@ public class SearchSettingsTest { @Test public void override_dirs() throws Exception { - File dataDir = temp.newFolder(), logDir = temp.newFolder(), tempDir = temp.newFolder(); + File dataDir = temp.newFolder(); + File logDir = temp.newFolder(); + File tempDir = temp.newFolder(); Props props = minProps(); props.set(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath()); props.set(ProcessProperties.PATH_LOGS, logDir.getAbsolutePath()); diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java index 398317ba38e..e5fe44f9283 100644 --- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java +++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java @@ -147,8 +147,11 @@ public class IssueIndexBenchmarkTest { } private static class IssueIterator implements Iterator<IssueDoc> { - private final int nbProjects, nbFilesPerProject, nbIssuesPerFile; - private int currentProject = 0, currentFile = 0; + private final int nbProjects; + private final int nbFilesPerProject; + private final int nbIssuesPerFile; + private int currentProject = 0; + private int currentFile = 0; private AtomicLong count = new AtomicLong(0L); private final Iterator<String> users = cycleIterator("guy", 200); private Iterator<String> rules = cycleIterator("squid:rule", 1000); diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/SourceIndexBenchmarkTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/SourceIndexBenchmarkTest.java index b050c237ebe..c1c529d7cb0 100644 --- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/SourceIndexBenchmarkTest.java +++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/SourceIndexBenchmarkTest.java @@ -20,6 +20,12 @@ package org.sonar.server.benchmark; +import java.util.Arrays; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Timer; +import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; @@ -27,12 +33,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.server.es.EsClient; import org.sonar.server.source.db.FileSourceDb; -import org.sonar.server.source.index.*; +import org.sonar.server.source.index.FileSourcesUpdaterHelper; +import org.sonar.server.source.index.SourceLineDoc; +import org.sonar.server.source.index.SourceLineIndex; +import org.sonar.server.source.index.SourceLineIndexDefinition; +import org.sonar.server.source.index.SourceLineIndexer; +import org.sonar.server.source.index.SourceLineResultSetIterator; import org.sonar.server.tester.ServerTester; -import java.util.*; -import java.util.concurrent.atomic.AtomicLong; - import static org.assertj.core.api.Assertions.assertThat; /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChart.java index 580ea9ba432..b7bbc7e0477 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChart.java @@ -19,7 +19,10 @@ */ package org.sonar.server.charts.deprecated; -import java.awt.*; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Transparency; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -135,8 +138,8 @@ public abstract class BaseChart { protected BasicStroke getDashedStroke(float width) { return new BasicStroke(width, - BasicStroke.CAP_BUTT, - BasicStroke.JOIN_MITER, - 10.0f, new float[] { 5.0f }, 0.0f); + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_MITER, + 10.0f, new float[] {5.0f}, 0.0f); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java index 04878089736..f9fb48293d4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java @@ -19,7 +19,8 @@ */ package org.sonar.server.charts.deprecated; -import java.awt.*; +import java.awt.Color; +import java.awt.Font; import java.util.Map; import java.util.StringTokenizer; import org.jfree.chart.JFreeChart; diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java index 9c122eca975..d7137fe2344 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java @@ -19,7 +19,7 @@ */ package org.sonar.server.charts.deprecated; -import java.awt.*; +import java.awt.Color; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Map; @@ -91,7 +91,7 @@ public class PieChart extends BaseChartWeb implements DeprecatedChart { private void configureDefaultColors() { PiePlot plot = (PiePlot) jfreechart.getPlot(); - for (int i=0 ; i<COLORS.length ; i++) { + for (int i = 0; i < COLORS.length; i++) { plot.setSectionPaint(Integer.toString(i), COLORS[i]); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java index 7db3f4775c9..8d528a61e41 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/widget/CoreWidget.java @@ -23,7 +23,9 @@ import org.sonar.api.web.AbstractRubyTemplate; import org.sonar.api.web.RubyRailsWidget; public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRailsWidget { - private String id, title, templatePath; + private String id; + private String title; + private String templatePath; protected CoreWidget(String id, String title, String templatePath) { this.id = id; diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseDataChange.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseDataChange.java index 0631b2e1cf2..75012719c1e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseDataChange.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/BaseDataChange.java @@ -35,7 +35,8 @@ public abstract class BaseDataChange implements DataChange, MigrationStep { @Override public final void execute() throws SQLException { - Connection readConnection = null, writeConnection = null; + Connection readConnection = null; + Connection writeConnection = null; try { readConnection = openConnection(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DataChange.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DataChange.java index 8b513ffcd2e..e87582df33d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DataChange.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DataChange.java @@ -28,7 +28,8 @@ public interface DataChange { class Context { private final Database db; - private final Connection readConnection, writeConnection; + private final Connection readConnection; + private final Connection writeConnection; public Context(Database db, Connection readConnection, Connection writeConnection) { this.db = db; diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdate.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdate.java index c670ae5333d..ffdf199c8bb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdate.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdate.java @@ -38,7 +38,8 @@ public class MassUpdate { } private final Database db; - private final Connection readConnection, writeConnection; + private final Connection readConnection; + private final Connection writeConnection; private final AtomicLong counter = new AtomicLong(0L); private final ProgressLogger progress = ProgressLogger.create(getClass(), counter); diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java index 8e8bea4e63f..479f5b20afa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java @@ -178,7 +178,9 @@ class ViolationConverter implements Callable<Object> { continue; } String issueKey = Uuids.create(); - String status, severity, reporter = null; + String status; + String severity; + String reporter = null; boolean manualSeverity; Object createdAt = Objects.firstNonNull(row.get(CREATED_AT), ONE_YEAR_AGO); Object updatedAt; diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java index 0000e546596..020382d0c21 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/AddMissingRuleParameterDefaultValuesMigrationStep.java @@ -96,8 +96,10 @@ public class AddMissingRuleParameterDefaultValuesMigrationStep extends BaseDataC } private static class RuleParam { - final Long id, ruleId; - final String defaultValue, name; + final Long id; + final Long ruleId; + final String defaultValue; + final String name; RuleParam(@Nullable Long id, @Nullable Long ruleId, @Nullable String name, @Nullable String defaultValue) { this.id = id; @@ -108,7 +110,8 @@ public class AddMissingRuleParameterDefaultValuesMigrationStep extends BaseDataC } private static class ActiveRule { - final Long id, profileId; + final Long id; + final Long profileId; ActiveRule(@Nullable Long id, @Nullable Long profileId) { this.id = id; diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java index e166f9cba0d..1adc45687bc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java @@ -170,7 +170,8 @@ public class DuplicationsParser { public static class Duplication { private final ComponentDto file; - private final Integer from, size; + private final Integer from; + private final Integer size; Duplication(@Nullable ComponentDto file, Integer from, Integer size) { this.file = file; diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java index 7317c20fabe..ce657a1a29b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java @@ -34,7 +34,9 @@ import java.util.concurrent.TimeUnit; public abstract class BaseIndexer implements Startable { private final ThreadPoolExecutor executor; - private final String indexName, typeName, dateFieldName; + private final String indexName; + private final String typeName; + private final String dateFieldName; protected final EsClient esClient; private volatile long lastUpdatedAt = -1L; diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java index e8b8bc7517e..fb136dc0fce 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/NewIndex.java @@ -175,7 +175,9 @@ public class NewIndex { public static class StringFieldBuilder { private final NewIndexType indexType; private final String fieldName; - private boolean docValues = false, disableSearch = false, hasAnalyzedField = false; + private boolean docValues = false; + private boolean disableSearch = false; + private boolean hasAnalyzedField = false; private SortedMap<String, Object> subFields = Maps.newTreeMap(); private StringFieldBuilder(NewIndexType indexType, String fieldName) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java index e3ca7507fa5..af2e830d861 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/request/ProxyBulkRequestBuilder.java @@ -83,7 +83,9 @@ public class ProxyBulkRequestBuilder extends BulkRequestBuilder { Multiset<BulkRequestKey> groupedRequests = LinkedHashMultiset.create(); for (int i = 0; i < request.requests().size(); i++) { ActionRequest<?> item = request.requests().get(i); - String requestType, index, docType; + String requestType; + String index; + String docType; if (item instanceof IndexRequest) { IndexRequest request = (IndexRequest) item; requestType = "index"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java b/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java index b8e82ee913d..a7389d20bcb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java +++ b/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java @@ -20,10 +20,10 @@ package org.sonar.server.event; import com.google.common.collect.Multimap; -import org.sonar.api.notifications.*; - import java.util.Collection; import java.util.Map; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.notification.NotificationDispatcher; import org.sonar.server.notification.NotificationDispatcherMetadata; import org.sonar.server.notification.NotificationManager; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogDiffFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogDiffFormat.java index ae8b6909fc9..8c8fc28bc18 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogDiffFormat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelogDiffFormat.java @@ -24,7 +24,8 @@ import javax.annotation.Nullable; public class IssueChangelogDiffFormat { - private String oldValue, newValue; + private String oldValue; + private String newValue; public IssueChangelogDiffFormat(@Nullable String oldValue, @Nullable String newValue) { this.oldValue = oldValue; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index efbe0b67abe..9a8da1edca1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -20,6 +20,13 @@ package org.sonar.server.issue.index; import com.google.common.collect.Maps; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.lang.BooleanUtils; import org.sonar.api.issue.Issue; import org.sonar.api.issue.IssueComment; @@ -29,11 +36,6 @@ import org.sonar.api.utils.Duration; import org.sonar.api.utils.KeyValueFormat; import org.sonar.server.search.BaseDoc; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; - public class IssueDoc extends BaseDoc implements Issue { public IssueDoc(Map<String, Object> fields) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcher.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcher.java index 5aa290eb83b..305045ad5e1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcher.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcher.java @@ -21,10 +21,11 @@ package org.sonar.server.issue.notification; import com.google.common.base.Objects; import com.google.common.collect.Multimap; -import org.sonar.api.notifications.*; import javax.annotation.Nullable; import java.util.Collection; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.notification.NotificationDispatcher; import org.sonar.server.notification.NotificationDispatcherMetadata; import org.sonar.server.notification.NotificationManager; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationDispatcher.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationDispatcher.java index 6c28a8aadf9..2d29f388a48 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationDispatcher.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotificationDispatcher.java @@ -20,10 +20,10 @@ package org.sonar.server.issue.notification; import com.google.common.collect.Multimap; -import org.sonar.api.notifications.*; - import java.util.Collection; import java.util.Map; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.notification.NotificationDispatcher; import org.sonar.server.notification.NotificationDispatcherMetadata; import org.sonar.server.notification.NotificationManager; diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilter.java b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilter.java index 0dd3f518206..d3e0b45979a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilter.java @@ -46,7 +46,8 @@ public class MeasureFilter { private List<String> resourceQualifiers = Collections.emptyList(); private String resourceKey = null; private String resourceName = null; - private Date fromDate = null, toDate = null; + private Date fromDate = null; + private Date toDate = null; private boolean userFavourites = false; // conditions on measures diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java index 4e4843fab17..7d9601d33ee 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java @@ -48,7 +48,8 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable { private static final Logger LOGGER = Loggers.get(DefaultServerFileSystem.class); private final Server server; - private final File homeDir, tempDir; + private final File homeDir; + private final File tempDir; public DefaultServerFileSystem(Settings settings, Server server) { this.server = server; diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkChangeResult.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkChangeResult.java index 5a633b6b4fe..92bce979185 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkChangeResult.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BulkChangeResult.java @@ -33,7 +33,8 @@ public class BulkChangeResult { private final QualityProfileDto profile; private final Errors errors = new Errors(); - private int succeeded = 0, failed = 0; + private int succeeded = 0; + private int failed = 0; private final List<ActiveRuleChange> changes = Lists.newArrayList(); public BulkChangeResult() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java index e650081860d..b46818c688d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java @@ -110,7 +110,8 @@ public class QProfileBackuper { */ public BulkChangeResult restore(Reader reader, @Nullable QProfileName toProfileName) { try { - String profileLang = null, profileName = null; + String profileLang = null; + String profileName = null; List<RuleActivation> ruleActivations = Lists.newArrayList(); SMInputFactory inputFactory = initStax(); SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); @@ -146,7 +147,9 @@ public class QProfileBackuper { List<RuleKey> duplicatedKeys = Lists.newArrayList(); while (rulesCursor.getNext() != null) { SMInputCursor ruleCursor = rulesCursor.childElementCursor(); - String repositoryKey = null, key = null, severity = null; + String repositoryKey = null; + String key = null; + String severity = null; Map<String, String> parameters = Maps.newHashMap(); while (ruleCursor.getNext() != null) { String nodeName = ruleCursor.getLocalName(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java index d794058ea97..88427ee432f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java @@ -22,7 +22,8 @@ package org.sonar.server.qualityprofile; import javax.annotation.Nullable; public class QProfileName { - private final String lang, name; + private final String lang; + private final String name; public QProfileName(String lang, String name) { this.lang = lang; diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java index 12aa30cf88e..bdab3b3ca73 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java @@ -43,8 +43,10 @@ class RuleActivatorContext { private RuleDto rule; private final Map<String, RuleParamDto> ruleParams = Maps.newHashMap(); private QualityProfileDto profile; - private ActiveRuleDto activeRule, parentActiveRule; - private final Map<String, ActiveRuleParamDto> activeRuleParams = Maps.newHashMap(), parentActiveRuleParams = Maps.newHashMap(); + private ActiveRuleDto activeRule; + private ActiveRuleDto parentActiveRule; + private final Map<String, ActiveRuleParamDto> activeRuleParams = Maps.newHashMap(); + private final Map<String, ActiveRuleParamDto> parentActiveRuleParams = Maps.newHashMap(); RuleActivatorContext() { } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java index af462f70cd5..a39b72afcc3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java @@ -22,7 +22,8 @@ package org.sonar.server.qualityprofile.ws; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.SearchHit; import org.sonar.api.resources.Languages; -import org.sonar.api.server.ws.*; +import org.sonar.api.server.ws.Request; +import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService.NewAction; import org.sonar.api.server.ws.WebService.NewController; import org.sonar.api.server.ws.WebService.Param; diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/NewRule.java b/server/sonar-server/src/main/java/org/sonar/server/rule/NewRule.java index 6af6fa8f369..268661896d5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/NewRule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/NewRule.java @@ -34,11 +34,16 @@ public class NewRule { private String ruleKey; private RuleKey templateKey; - private String name, htmlDescription, markdownDescription, severity; + private String name; + private String htmlDescription; + private String markdownDescription; + private String severity; private RuleStatus status; private final Map<String, String> parameters = Maps.newHashMap(); - private boolean isCustom, isManual, preventReactivation = false; + private boolean isCustom; + private boolean isManual; + private boolean preventReactivation = false; private NewRule() { // No direct call to constructor diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java index 9fbb676dc7c..55852d336dc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleRepositories.java @@ -45,7 +45,9 @@ import java.util.SortedSet; public class RuleRepositories { public static class Repository implements Comparable<Repository> { - private final String key, name, language; + private final String key; + private final String name; + private final String language; private Repository(RulesDefinition.Repository repoDef) { this.key = repoDef.key(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdate.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdate.java index acfc5b737f6..b8eb6f25f75 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdate.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdate.java @@ -37,15 +37,25 @@ public class RuleUpdate { private final RuleKey ruleKey; - private boolean changeTags = false, changeMarkdownNote = false, changeDebtSubCharacteristic = false, changeDebtRemediationFunction = false, - changeName = false, changeDescription = false, changeSeverity = false, changeStatus = false, changeParameters = false; - private boolean isCustomRule, isManual; + private boolean changeTags = false; + private boolean changeMarkdownNote = false; + private boolean changeDebtSubCharacteristic = false; + private boolean changeDebtRemediationFunction = false; + private boolean changeName = false; + private boolean changeDescription = false; + private boolean changeSeverity = false; + private boolean changeStatus = false; + private boolean changeParameters = false; + private boolean isCustomRule; + private boolean isManual; private Set<String> tags; private String markdownNote; private String debtSubCharacteristicKey; private DebtRemediationFunction debtRemediationFunction; - private String name, markdownDescription, severity; + private String name; + private String markdownDescription; + private String severity; private RuleStatus status; private final Map<String, String> parameters = Maps.newHashMap(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java index 4562695bb3b..482f9363b54 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java @@ -25,6 +25,16 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -32,7 +42,15 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequestBuilder; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.index.query.*; +import org.elasticsearch.index.query.BoolFilterBuilder; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.FilterBuilder; +import org.elasticsearch.index.query.FilterBuilders; +import org.elasticsearch.index.query.HasParentFilterBuilder; +import org.elasticsearch.index.query.MatchQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.SimpleQueryStringBuilder; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.aggregations.AggregationBuilders; @@ -49,12 +67,13 @@ import org.sonar.api.server.debt.DebtCharacteristic; import org.sonar.core.rule.RuleDto; import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer; import org.sonar.server.rule.Rule; -import org.sonar.server.search.*; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; +import org.sonar.server.search.BaseIndex; +import org.sonar.server.search.IndexDefinition; +import org.sonar.server.search.IndexField; +import org.sonar.server.search.QueryContext; +import org.sonar.server.search.Result; +import org.sonar.server.search.SearchClient; +import org.sonar.server.search.StickyFacetBuilder; import static com.google.common.collect.Lists.newArrayList; @@ -428,14 +447,14 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { /* * Since this facet concerns 2 fields, we're using an aggregation structure like this: * global aggregation - * |- sub-aggregation on characteristics: filter - * | |- classic sub-aggregation with top-n terms, excluding NONE - * | |- classic sub-aggregation with selected terms - * | |- terms aggregation on "NONE" - * | |- missing aggregation - * |- sub-aggregation on sub-characteristics: filter, excluding NONE - * |- classic sub-aggregation with top-n terms - * |- classic sub-aggregation with selected terms + * |- sub-aggregation on characteristics: filter + * | |- classic sub-aggregation with top-n terms, excluding NONE + * | |- classic sub-aggregation with selected terms + * | |- terms aggregation on "NONE" + * | |- missing aggregation + * |- sub-aggregation on sub-characteristics: filter, excluding NONE + * |- classic sub-aggregation with top-n terms + * |- classic sub-aggregation with selected terms */ int characsSize = 10; int subCharacsSize = 300; @@ -454,8 +473,8 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { .size(characsSize)) .subAggregation( AggregationBuilders.terms(FACET_DEBT_CHARACTERISTICS + "__chars_none").field(RuleNormalizer.RuleField.CHARACTERISTIC.field()) - .include(DebtCharacteristic.NONE) - .size(characsSize)) + .include(DebtCharacteristic.NONE) + .size(characsSize)) .subAggregation( AggregationBuilders.missing(FACET_DEBT_CHARACTERISTICS + "__chars_missing").field(RuleNormalizer.RuleField.CHARACTERISTIC.field())); AggregationBuilder debtSubChar = AggregationBuilders.filter(FACET_DEBT_CHARACTERISTICS + "__subchars") diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/Result.java b/server/sonar-server/src/main/java/org/sonar/server/search/Result.java index ee2901cdf7a..166948433a9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/Result.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/Result.java @@ -20,15 +20,17 @@ package org.sonar.server.search; import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.SearchHit; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; - public class Result<K> { private final List<K> hits; diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java index 2b5973c3941..b45d76e4b2c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java @@ -54,7 +54,17 @@ import org.picocontainer.Startable; import org.sonar.api.config.Settings; import org.sonar.process.LoopbackAddress; import org.sonar.process.ProcessProperties; -import org.sonar.server.es.request.*; +import org.sonar.server.es.request.ProxyBulkRequestBuilder; +import org.sonar.server.es.request.ProxyCountRequestBuilder; +import org.sonar.server.es.request.ProxyCreateIndexRequestBuilder; +import org.sonar.server.es.request.ProxyDeleteRequestBuilder; +import org.sonar.server.es.request.ProxyGetRequestBuilder; +import org.sonar.server.es.request.ProxyIndicesExistsRequestBuilder; +import org.sonar.server.es.request.ProxyMultiGetRequestBuilder; +import org.sonar.server.es.request.ProxyPutMappingRequestBuilder; +import org.sonar.server.es.request.ProxyRefreshRequestBuilder; +import org.sonar.server.es.request.ProxySearchRequestBuilder; +import org.sonar.server.es.request.ProxySearchScrollRequestBuilder; /** * ElasticSearch Node used to connect to index. diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterDashboards.java b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterDashboards.java index f291915fdf0..4e6cb6c05cc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterDashboards.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterDashboards.java @@ -21,22 +21,26 @@ package org.sonar.server.startup; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Map.Entry; import org.picocontainer.Startable; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.api.utils.log.Profiler; import org.sonar.api.web.Dashboard; import org.sonar.api.web.DashboardTemplate; -import org.sonar.core.dashboard.*; +import org.sonar.core.dashboard.ActiveDashboardDao; +import org.sonar.core.dashboard.ActiveDashboardDto; +import org.sonar.core.dashboard.DashboardDao; +import org.sonar.core.dashboard.DashboardDto; +import org.sonar.core.dashboard.WidgetDto; +import org.sonar.core.dashboard.WidgetPropertyDto; import org.sonar.core.template.LoadedTemplateDao; import org.sonar.core.template.LoadedTemplateDto; import org.sonar.server.issue.filter.RegisterIssueFilters; -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Map.Entry; - /** * @since 2.13 */ diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UpdateUser.java b/server/sonar-server/src/main/java/org/sonar/server/user/UpdateUser.java index 9df8c294f84..9cf5bb35575 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UpdateUser.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UpdateUser.java @@ -37,7 +37,10 @@ public class UpdateUser { private String password; private String passwordConfirmation; - boolean isNameChanged, isEmailChanged, isScmAccountsChanged, isPasswordChanged; + boolean isNameChanged; + boolean isEmailChanged; + boolean isScmAccountsChanged; + boolean isPasswordChanged; private UpdateUser(String login) { // No direct call to this constructor diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserSessionFilter.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserSessionFilter.java index 7663fd48017..9ede4ff6ccb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserSessionFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserSessionFilter.java @@ -19,8 +19,13 @@ */ package org.sonar.server.user; -import javax.servlet.*; import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import org.sonar.api.utils.log.Loggers; import org.sonar.server.platform.Platform; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/DumbComponent.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/DumbComponent.java index 4d0a988a3c6..46a1e09ac61 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/DumbComponent.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/DumbComponent.java @@ -40,7 +40,10 @@ public class DumbComponent implements Component { private final Type type; private final int ref; - private final String uuid, key, name, version; + private final String uuid; + private final String key; + private final String name; + private final String version; private final FileAttributes fileAttributes; private final List<Component> children; @@ -127,7 +130,10 @@ public class DumbComponent implements Component { public static final class Builder { private final Type type; private final int ref; - private String uuid, key, name, version; + private String uuid; + private String key; + private String name; + private String version; private FileAttributes fileAttributes; private final List<Component> children = new ArrayList<>(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java index 87294983877..f50bc0e2cd9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java @@ -20,7 +20,11 @@ package org.sonar.server.computation.step; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.issue.Issue; import org.sonar.api.issue.internal.DefaultIssue; @@ -87,18 +91,18 @@ public class PersistIssuesStepTest extends BaseStepTest { dbTester.prepareDbUnit(getClass(), "insert_new_issue.xml"); issueCache.newAppender().append(new DefaultIssue() - .setKey("ISSUE") - .setRuleKey(RuleKey.of("xoo", "S01")) - .setComponentUuid("COMPONENT") - .setProjectUuid("PROJECT") - .setSeverity(Severity.BLOCKER) - .setStatus(Issue.STATUS_OPEN) - .setNew(true) - ).close(); + .setKey("ISSUE") + .setRuleKey(RuleKey.of("xoo", "S01")) + .setComponentUuid("COMPONENT") + .setProjectUuid("PROJECT") + .setSeverity(Severity.BLOCKER) + .setStatus(Issue.STATUS_OPEN) + .setNew(true) + ).close(); step.execute(); - dbTester.assertDbUnit(getClass(), "insert_new_issue-result.xml", new String[]{"id"}, "issues"); + dbTester.assertDbUnit(getClass(), "insert_new_issue-result.xml", new String[] {"id"}, "issues"); } @Test @@ -106,16 +110,16 @@ public class PersistIssuesStepTest extends BaseStepTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); issueCache.newAppender().append(new DefaultIssue() - .setKey("ISSUE") - .setRuleKey(RuleKey.of("xoo", "S01")) - .setComponentUuid("COMPONENT") - .setProjectUuid("PROJECT") - .setSeverity(Severity.BLOCKER) - .setStatus(Issue.STATUS_CLOSED) - .setResolution(Issue.RESOLUTION_FIXED) - .setNew(false) - .setChanged(true) - ).close(); + .setKey("ISSUE") + .setRuleKey(RuleKey.of("xoo", "S01")) + .setComponentUuid("COMPONENT") + .setProjectUuid("PROJECT") + .setSeverity(Severity.BLOCKER) + .setStatus(Issue.STATUS_CLOSED) + .setResolution(Issue.RESOLUTION_FIXED) + .setNew(false) + .setChanged(true) + ).close(); step.execute(); @@ -127,27 +131,27 @@ public class PersistIssuesStepTest extends BaseStepTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); issueCache.newAppender().append(new DefaultIssue() - .setKey("ISSUE") - .setRuleKey(RuleKey.of("xoo", "S01")) - .setComponentUuid("COMPONENT") - .setProjectUuid("PROJECT") - .setSeverity(Severity.BLOCKER) - .setStatus(Issue.STATUS_CLOSED) - .setResolution(Issue.RESOLUTION_FIXED) - .setNew(false) - .setChanged(true) - .addComment(new DefaultIssueComment() - .setKey("COMMENT") - .setIssueKey("ISSUE") - .setUserLogin("john") - .setMarkdownText("Some text") - .setNew(true) - ) - ).close(); + .setKey("ISSUE") + .setRuleKey(RuleKey.of("xoo", "S01")) + .setComponentUuid("COMPONENT") + .setProjectUuid("PROJECT") + .setSeverity(Severity.BLOCKER) + .setStatus(Issue.STATUS_CLOSED) + .setResolution(Issue.RESOLUTION_FIXED) + .setNew(false) + .setChanged(true) + .addComment(new DefaultIssueComment() + .setKey("COMMENT") + .setIssueKey("ISSUE") + .setUserLogin("john") + .setMarkdownText("Some text") + .setNew(true) + ) + ).close(); step.execute(); - dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[]{"id", "created_at", "updated_at"}, "issue_changes"); + dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[] {"id", "created_at", "updated_at"}, "issue_changes"); } @Test @@ -155,25 +159,25 @@ public class PersistIssuesStepTest extends BaseStepTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); issueCache.newAppender().append(new DefaultIssue() - .setKey("ISSUE") - .setRuleKey(RuleKey.of("xoo", "S01")) - .setComponentUuid("COMPONENT") - .setProjectUuid("PROJECT") - .setSeverity(Severity.BLOCKER) - .setStatus(Issue.STATUS_CLOSED) - .setResolution(Issue.RESOLUTION_FIXED) - .setNew(false) - .setChanged(true) - .setCurrentChange(new FieldDiffs() - .setIssueKey("ISSUE") - .setUserLogin("john") - .setDiff("technicalDebt", null, 1L) - ) - ).close(); + .setKey("ISSUE") + .setRuleKey(RuleKey.of("xoo", "S01")) + .setComponentUuid("COMPONENT") + .setProjectUuid("PROJECT") + .setSeverity(Severity.BLOCKER) + .setStatus(Issue.STATUS_CLOSED) + .setResolution(Issue.RESOLUTION_FIXED) + .setNew(false) + .setChanged(true) + .setCurrentChange(new FieldDiffs() + .setIssueKey("ISSUE") + .setUserLogin("john") + .setDiff("technicalDebt", null, 1L) + ) + ).close(); step.execute(); - dbTester.assertDbUnit(getClass(), "add_change-result.xml", new String[]{"id", "created_at", "updated_at"}, "issue_changes"); + dbTester.assertDbUnit(getClass(), "add_change-result.xml", new String[] {"id", "created_at", "updated_at"}, "issue_changes"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/AddColumnsBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/AddColumnsBuilderTest.java index ba94a71598b..a7c9f19340a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/AddColumnsBuilderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/AddColumnsBuilderTest.java @@ -20,7 +20,11 @@ package org.sonar.server.db.migrations; import org.junit.Test; -import org.sonar.core.persistence.dialect.*; +import org.sonar.core.persistence.dialect.H2; +import org.sonar.core.persistence.dialect.MsSql; +import org.sonar.core.persistence.dialect.MySql; +import org.sonar.core.persistence.dialect.Oracle; +import org.sonar.core.persistence.dialect.PostgreSql; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java index 3604426eff2..1c7f7dcedc7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java @@ -36,7 +36,8 @@ import java.util.Properties; public class EsServerHolder { private static EsServerHolder HOLDER = null; - private final String clusterName, nodeName; + private final String clusterName; + private final String nodeName; private final int port; private final String hostName; private final File homeDir; diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcherTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcherTest.java index a11fd69465c..378b4697631 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcherTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcherTest.java @@ -26,7 +26,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.sonar.api.notifications.*; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.notification.NotificationDispatcher; import org.sonar.server.notification.NotificationDispatcherMetadata; import org.sonar.server.notification.NotificationManager; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java index ecd7e1235c8..c76854a0465 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java @@ -19,24 +19,32 @@ */ package org.sonar.server.permission; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.sonar.core.permission.*; +import org.sonar.core.permission.GroupWithPermission; +import org.sonar.core.permission.GroupWithPermissionDto; +import org.sonar.core.permission.PermissionDao; +import org.sonar.core.permission.PermissionQuery; +import org.sonar.core.permission.PermissionTemplateDao; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.permission.UserWithPermissionDto; import org.sonar.core.resource.ResourceDao; import org.sonar.core.resource.ResourceDto; import org.sonar.core.resource.ResourceQuery; import org.sonar.server.exceptions.NotFoundException; -import java.util.List; - import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.mockito.Matchers.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -64,7 +72,7 @@ public class PermissionFinderTest { public void find_users() { when(permissionDao.selectUsers(any(PermissionQuery.class), anyLong(), anyInt(), anyInt())).thenReturn( newArrayList(new UserWithPermissionDto().setName("user1").setPermission("user")) - ); + ); UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").build()); assertThat(result.users()).hasSize(1); @@ -101,7 +109,7 @@ public class PermissionFinderTest { new UserWithPermissionDto().setName("user1").setPermission("user"), new UserWithPermissionDto().setName("user2").setPermission("user"), new UserWithPermissionDto().setName("user3").setPermission("user")) - ); + ); UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").pageIndex(1).pageSize(2).build()); ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); @@ -120,7 +128,7 @@ public class PermissionFinderTest { new UserWithPermissionDto().setName("user2").setPermission("user"), new UserWithPermissionDto().setName("user4").setPermission("user"), new UserWithPermissionDto().setName("user3").setPermission("user")) - ); + ); UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").pageIndex(1).pageSize(10).build()); ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); @@ -136,7 +144,7 @@ public class PermissionFinderTest { public void find_groups() { when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) - ); + ); GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder().permission("user").membership(PermissionQuery.IN).build()); @@ -152,7 +160,7 @@ public class PermissionFinderTest { new GroupWithPermissionDto().setName("Users").setPermission(null), new GroupWithPermissionDto().setName("Reviewers").setPermission(null), new GroupWithPermissionDto().setName("Other").setPermission(null) - )); + )); GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder() @@ -183,7 +191,7 @@ public class PermissionFinderTest { new GroupWithPermissionDto().setName("Users").setPermission(null), new GroupWithPermissionDto().setName("Reviewers").setPermission(null), new GroupWithPermissionDto().setName("Other").setPermission(null) - )); + )); assertThat(finder.findGroupsWithPermission( PermissionQuery.builder().permission("user").membership(PermissionQuery.IN).build()).groups()).hasSize(2); @@ -197,9 +205,9 @@ public class PermissionFinderTest { public void find_groups_with_added_anyone_group() { when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) - ); + ); - GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder().permission("user") + GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user") .pageIndex(1).membership(PermissionQuery.ANY).build()); assertThat(result.groups()).hasSize(2); GroupWithPermission first = result.groups().get(0); @@ -211,7 +219,7 @@ public class PermissionFinderTest { public void find_groups_without_adding_anyone_group_when_search_text_do_not_matched() { when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) - ); + ); GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user").search("other") .pageIndex(1).membership(PermissionQuery.ANY).build()); @@ -223,7 +231,7 @@ public class PermissionFinderTest { public void find_groups_with_added_anyone_group_when_search_text_matched() { when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("MyAnyGroup").setPermission("user")) - ); + ); GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user").search("any") .pageIndex(1).membership(PermissionQuery.ANY).build()); @@ -234,22 +242,21 @@ public class PermissionFinderTest { public void find_groups_without_adding_anyone_group_when_out_membership_selected() { when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) - ); + ); - GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder().permission("user") + GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user") .pageIndex(1).membership(PermissionQuery.OUT).build()); // Anyone group should not be added assertThat(result.groups()).hasSize(1); } - @Test public void find_users_from_permission_template() { when(permissionTemplateDao.selectTemplateByKey(anyString())).thenReturn(new PermissionTemplateDto().setId(1L).setKee("my_template")); when(permissionTemplateDao.selectUsers(any(PermissionQuery.class), anyLong(), anyInt(), anyInt())).thenReturn( newArrayList(new UserWithPermissionDto().setName("user1").setPermission("user")) - ); + ); UserWithPermissionQueryResult result = finder.findUsersWithPermissionTemplate(PermissionQuery.builder().permission("user").template("my_template").build()); assertThat(result.users()).hasSize(1); @@ -274,7 +281,7 @@ public class PermissionFinderTest { when(permissionTemplateDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) - ); + ); GroupWithPermissionQueryResult result = finder.findGroupsWithPermissionTemplate( PermissionQuery.builder().permission("user").template("my_template").membership(PermissionQuery.OUT).build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java index f8891e1eb02..2574a399ddf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java @@ -20,6 +20,7 @@ package org.sonar.server.qualityprofile; +import java.util.Map; import org.junit.After; import org.junit.Test; import org.sonar.api.profiles.ProfileDefinition; @@ -33,7 +34,11 @@ import org.sonar.api.server.rule.RuleParamType; import org.sonar.api.server.rule.RulesDefinition; import org.sonar.api.utils.ValidationMessages; import org.sonar.core.persistence.DbSession; -import org.sonar.core.qualityprofile.db.*; +import org.sonar.core.qualityprofile.db.ActiveRuleDto; +import org.sonar.core.qualityprofile.db.ActiveRuleKey; +import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; +import org.sonar.core.qualityprofile.db.QualityProfileDao; +import org.sonar.core.qualityprofile.db.QualityProfileDto; import org.sonar.core.template.LoadedTemplateDto; import org.sonar.server.db.DbClient; import org.sonar.server.platform.Platform; @@ -41,8 +46,6 @@ import org.sonar.server.qualityprofile.db.ActiveRuleDao; import org.sonar.server.qualityprofile.index.ActiveRuleIndex; import org.sonar.server.tester.ServerTester; -import java.util.Map; - import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java index 083e2034e28..f2e0f48c603 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java @@ -61,7 +61,8 @@ public class DeleteActionTest { private ComponentDao componentDao; - private Language xoo1, xoo2; + private Language xoo1; + private Language xoo2; private WsTester tester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java index d87d18ab36d..733e0351348 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java @@ -20,6 +20,8 @@ package org.sonar.server.qualityprofile.ws; import com.google.common.collect.Sets; +import java.io.IOException; +import java.io.Writer; import org.apache.commons.lang.StringUtils; import org.junit.After; import org.junit.Before; @@ -40,16 +42,18 @@ import org.sonar.core.qualityprofile.db.QualityProfileDto; import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.language.LanguageTesting; -import org.sonar.server.qualityprofile.*; +import org.sonar.server.qualityprofile.ActiveRule; +import org.sonar.server.qualityprofile.QProfileBackuper; +import org.sonar.server.qualityprofile.QProfileExporters; +import org.sonar.server.qualityprofile.QProfileFactory; +import org.sonar.server.qualityprofile.QProfileLoader; +import org.sonar.server.qualityprofile.QProfileTesting; import org.sonar.server.qualityprofile.index.ActiveRuleIndex; import org.sonar.server.search.IndexClient; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; import org.sonar.server.ws.WsTester.Result; -import java.io.IOException; -import java.io.Writer; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java index 097531c9741..7393b198da9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java @@ -64,9 +64,13 @@ public class ProjectsActionTest { private DbSession session; - private QualityProfileDto xooP1, xooP2; + private QualityProfileDto xooP1; + private QualityProfileDto xooP2; - private ComponentDto project1, project2, project3, project4; + private ComponentDto project1; + private ComponentDto project2; + private ComponentDto project3; + private ComponentDto project4; private Long userId = 42L; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java index ca2963ab26e..56930f9d279 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsTest.java @@ -48,7 +48,8 @@ public class QProfilesWsTest { WebService.Controller controller; - String xoo1Key = "xoo1", xoo2Key = "xoo2"; + String xoo1Key = "xoo1"; + String xoo2Key = "xoo2"; @Before public void setUp() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java index d5d70d40cb6..af38b8cdcab 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java @@ -51,7 +51,8 @@ public class RenameActionTest { private QualityProfileDao qualityProfileDao; - private String xoo1Key = "xoo1", xoo2Key = "xoo2"; + private String xoo1Key = "xoo1"; + private String xoo2Key = "xoo2"; private WsTester tester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index 7b538b1fb4e..4ef6a789662 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -52,7 +52,8 @@ public class SearchActionTest { private QualityProfileDao qualityProfileDao; - private Language xoo1, xoo2; + private Language xoo1; + private Language xoo2; private WsTester tester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java index 1c543a0a1b5..06fc865302e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java @@ -54,7 +54,8 @@ public class SetDefaultActionTest { private QualityProfileDao qualityProfileDao; - private String xoo1Key = "xoo1", xoo2Key = "xoo2"; + private String xoo1Key = "xoo1"; + private String xoo2Key = "xoo2"; private WsTester tester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java index 5a5888725ef..fee5591d673 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java @@ -68,7 +68,8 @@ public class RuleUpdaterMediumTest { DbSession dbSession; BaseIndex<Rule, RuleDto, RuleKey> ruleIndex = tester.get(RuleIndex.class); RuleUpdater updater = tester.get(RuleUpdater.class); - int softReliabilityId, hardReliabilityId; + int softReliabilityId; + int hardReliabilityId; @Before public void before() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java index 6b5b9a57962..6de35e43f02 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java @@ -72,7 +72,8 @@ public class RulesWsMediumTest { RulesWs ws; RuleDao ruleDao; DbSession session; - int softReliabilityId, hardReliabilityId; + int softReliabilityId; + int hardReliabilityId; @Before public void setUp() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java b/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java index 8a06aa5f0f3..39eb6b239a3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java +++ b/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContext.java @@ -20,13 +20,24 @@ package org.sonar.server.tester; import com.google.common.collect.Maps; - -import javax.servlet.*; -import javax.servlet.descriptor.JspConfigDescriptor; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.util.*; +import java.util.Collections; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.Map; +import java.util.Set; +import javax.servlet.Filter; +import javax.servlet.FilterRegistration; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import javax.servlet.SessionCookieConfig; +import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; /** * A dummy implementation of {@link ServletContext} which only implements the attribute related methods. All other diff --git a/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java b/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java index ac3d7df6921..35285ccbed6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java @@ -20,14 +20,20 @@ package org.sonar.server.tester; import com.google.common.collect.ImmutableSet; -import org.junit.Test; - -import javax.servlet.*; - import java.io.IOException; import java.util.Collections; import java.util.Enumeration; import java.util.EventListener; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.Servlet; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.SessionTrackingMode; +import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java index cf3a4da36c7..dacae4737fa 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/GroupMembershipFinderTest.java @@ -23,11 +23,21 @@ package org.sonar.server.user; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.sonar.core.user.*; +import org.sonar.core.user.GroupMembership; +import org.sonar.core.user.GroupMembershipDao; +import org.sonar.core.user.GroupMembershipDto; +import org.sonar.core.user.GroupMembershipQuery; +import org.sonar.core.user.UserDao; +import org.sonar.core.user.UserDto; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.anyLong; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class GroupMembershipFinderTest { @@ -46,7 +56,7 @@ public class GroupMembershipFinderTest { GroupMembershipQuery query = GroupMembershipQuery.builder().login("arthur").build(); when(groupMembershipDao.selectGroups(eq(query), anyLong(), anyInt(), anyInt())).thenReturn( newArrayList(new GroupMembershipDto().setId(1L).setName("users").setDescription("Users group").setUserId(100L)) - ); + ); GroupMembershipFinder.Membership result = finder.find(query); assertThat(result.groups()).hasSize(1); @@ -79,7 +89,7 @@ public class GroupMembershipFinderTest { new GroupMembershipDto().setId(1L).setName("group1"), new GroupMembershipDto().setId(2L).setName("group2"), new GroupMembershipDto().setId(3L).setName("group3")) - ); + ); GroupMembershipFinder.Membership result = finder.find(query); ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); @@ -99,7 +109,7 @@ public class GroupMembershipFinderTest { new GroupMembershipDto().setId(2L).setName("group2"), new GroupMembershipDto().setId(3L).setName("group3"), new GroupMembershipDto().setId(4L).setName("group4")) - ); + ); GroupMembershipFinder.Membership result = finder.find(query); ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java index 057e5975c3b..74bf4ddb82e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/util/CloseableIteratorTest.java @@ -206,7 +206,8 @@ public class CloseableIteratorTest { } static class RemovableCloseableIterator extends CloseableIterator { - boolean isClosed = false, isRemoved = false; + boolean isClosed = false; + boolean isRemoved = false; @Override protected Object doNext() { diff --git a/sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java b/sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java index 429a776ba3e..6caeb32504f 100644 --- a/sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java +++ b/sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java @@ -40,7 +40,10 @@ public class PropsBuilderTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); - File homeDir, dataDir, webDir, logsDir; + File homeDir; + File dataDir; + File webDir; + File logsDir; JdbcSettings jdbcSettings = mock(JdbcSettings.class); @Before diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java index 1571119eb99..167f7aabd87 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java @@ -26,8 +26,13 @@ import java.util.HashMap; import java.util.Map; public class ActiveRule { - private final String repositoryKey, ruleKey, templateRuleKey; - private final String name, severity, internalKey, language; + private final String repositoryKey; + private final String ruleKey; + private final String templateRuleKey; + private final String name; + private final String severity; + private final String internalKey; + private final String language; private final Map<String, String> params = new HashMap<>(); public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java index 803560c176a..9cff3783ede 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ProjectRepositories.java @@ -19,12 +19,15 @@ */ package org.sonar.batch.protocol.input; -import org.sonar.batch.protocol.GsonHelper; - +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - -import java.util.*; +import org.sonar.batch.protocol.GsonHelper; /** * Container for all project data going from server to batch. diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/QProfile.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/QProfile.java index 4c6b0191046..3e98e0ffb5a 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/QProfile.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/QProfile.java @@ -23,7 +23,9 @@ import java.util.Date; public class QProfile { - private final String key, name, language; + private final String key; + private final String name; + private final String language; private final Date rulesUpdatedAt; public QProfile(String key, String name, String language, Date rulesUpdatedAt) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java index b68a51b1bf2..435b53d10db 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java @@ -48,7 +48,8 @@ public class BatchPluginPredicate implements Predicate<String> { private static final String PROPERTY_IS_DEPRECATED_MSG = "Property {0} is deprecated. Please use {1} instead."; private static final Joiner COMMA_JOINER = Joiner.on(", "); - private final Set<String> whites = newHashSet(), blacks = newHashSet(); + private final Set<String> whites = newHashSet(); + private final Set<String> blacks = newHashSet(); private final DefaultAnalysisMode mode; public BatchPluginPredicate(Settings settings, DefaultAnalysisMode mode) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java index a85eb172cf7..719800f8231 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshot.java @@ -38,7 +38,8 @@ import static org.sonar.api.utils.DateUtils.longToDate; public class PastSnapshot { private int index; - private String mode, modeParameter; + private String mode; + private String modeParameter; private Snapshot projectSnapshot; private Date targetDate = null; diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java index 687adba5178..48d051bf86e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java @@ -19,13 +19,17 @@ */ package org.sonar.batch.profiling; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; import org.sonar.api.utils.System2; import org.sonar.api.utils.TimeUtils; -import javax.annotation.Nullable; - -import java.util.*; - public abstract class AbstractTimeProfiling { private final long startTime; 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 f4bae408420..72f150aa9c5 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 @@ -20,14 +20,15 @@ package org.sonar.batch.profiling; import com.google.common.collect.Maps; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import javax.annotation.Nullable; import org.sonar.api.resources.Project; import org.sonar.api.utils.System2; -import javax.annotation.Nullable; - -import java.util.*; -import java.util.Map.Entry; - public class ModuleProfiling extends AbstractTimeProfiling { private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<>(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java index c62c528c2fb..97e5c09dcdb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java @@ -21,12 +21,28 @@ package org.sonar.batch.profiling; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; +import java.io.File; +import java.io.FileOutputStream; +import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.CoreProperties; import org.sonar.api.batch.Decorator; -import org.sonar.api.batch.events.*; +import org.sonar.api.batch.events.DecoratorExecutionHandler; +import org.sonar.api.batch.events.DecoratorsPhaseHandler; +import org.sonar.api.batch.events.InitializerExecutionHandler; +import org.sonar.api.batch.events.InitializersPhaseHandler; +import org.sonar.api.batch.events.PostJobExecutionHandler; +import org.sonar.api.batch.events.PostJobsPhaseHandler; +import org.sonar.api.batch.events.ProjectAnalysisHandler; +import org.sonar.api.batch.events.SensorExecutionHandler; +import org.sonar.api.batch.events.SensorsPhaseHandler; import org.sonar.api.resources.Project; import org.sonar.api.utils.System2; import org.sonar.api.utils.TimeUtils; @@ -36,12 +52,6 @@ import org.sonar.batch.phases.event.PersisterExecutionHandler; import org.sonar.batch.phases.event.PersistersPhaseHandler; import org.sonar.batch.util.BatchUtils; -import javax.annotation.Nullable; - -import java.io.File; -import java.io.FileOutputStream; -import java.util.*; - import static org.sonar.batch.profiling.AbstractTimeProfiling.sortByDescendingTotalTime; import static org.sonar.batch.profiling.AbstractTimeProfiling.truncate; diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/language/Language.java b/sonar-batch/src/main/java/org/sonar/batch/repository/language/Language.java index 12241dab086..fcbf1e74c3e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/language/Language.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/language/Language.java @@ -24,7 +24,8 @@ import java.util.Collection; public final class Language { - private final String key, name; + private final String key; + private final String name; private final String[] fileSuffixes; public Language(String key, String name, String... fileSuffixes) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfile.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfile.java index 73bca934108..8ea56afa10c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfile.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfile.java @@ -25,7 +25,9 @@ import java.util.Date; public class QProfile { - private String key, name, language; + private String key; + private String name; + private String language; private Date rulesUpdatedAt; public String getKey() { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java index cc3e3798f07..10fa76df9be 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java @@ -438,7 +438,8 @@ public class ProjectReactorBuilder { @VisibleForTesting protected static File[] getLibraries(File baseDir, String pattern) { final int i = Math.max(pattern.lastIndexOf('/'), pattern.lastIndexOf('\\')); - final String dirPath, filePattern; + final String dirPath; + final String filePattern; if (i == -1) { dirPath = "."; filePattern = pattern; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java index d9e31778a3d..fd2e8a9226a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java @@ -37,7 +37,9 @@ import java.util.List; @BatchSide public class ModuleFileSystemInitializer { - private File baseDir, workingDir, buildDir; + private File baseDir; + private File workingDir; + private File buildDir; private List<File> sourceDirsOrFiles = Lists.newArrayList(); private List<File> testDirsOrFiles = Lists.newArrayList(); private List<File> binaryDirs = Lists.newArrayList(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java index 6bef676b656..20390af7c84 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java @@ -21,18 +21,22 @@ package org.sonar.batch.scan.filesystem; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.CharEncoding; -import org.sonar.api.batch.fs.FilePredicate; -import org.sonar.api.resources.*; -import org.sonar.api.scan.filesystem.PathResolver; -import org.sonar.api.utils.SonarException; - import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.Arrays; import java.util.List; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.CharEncoding; +import org.sonar.api.batch.fs.FilePredicate; +import org.sonar.api.resources.InputFile; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.Language; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.ProjectFileSystem; +import org.sonar.api.resources.Resource; +import org.sonar.api.scan.filesystem.PathResolver; +import org.sonar.api.utils.SonarException; /** * Adapter for keeping the backward-compatibility of the deprecated component {@link org.sonar.api.resources.ProjectFileSystem} diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java index 1d49d6318f7..9026b8c48d3 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java @@ -61,7 +61,8 @@ public class BatchExtensionDictionnaryTest { @Test public void testGetFilteredExtensionWithExtensionMatcher() { - final Sensor sensor1 = new FakeSensor(), sensor2 = new FakeSensor(); + final Sensor sensor1 = new FakeSensor(); + final Sensor sensor2 = new FakeSensor(); BatchExtensionDictionnary selector = newSelector(sensor1, sensor2); Collection<Sensor> sensors = selector.select(Sensor.class, null, true, new ExtensionMatcher() { @@ -77,7 +78,8 @@ public class BatchExtensionDictionnaryTest { @Test public void testGetFilteredExtensions() { - Sensor sensor1 = new FakeSensor(), sensor2 = new FakeSensor(); + Sensor sensor1 = new FakeSensor(); + Sensor sensor2 = new FakeSensor(); Decorator decorator = mock(Decorator.class); BatchExtensionDictionnary selector = newSelector(sensor1, sensor2, decorator); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/workflow/Transition.java b/sonar-core/src/main/java/org/sonar/core/issue/workflow/Transition.java index 4afc317c75c..fa4f3bbfef3 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/workflow/Transition.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/workflow/Transition.java @@ -31,7 +31,8 @@ import java.util.List; public class Transition { private final String key; - private final String from, to; + private final String from; + private final String to; private final Condition[] conditions; private final Function[] functions; private final boolean automatic; @@ -125,7 +126,8 @@ public class Transition { public static class TransitionBuilder { private final String key; - private String from, to; + private String from; + private String to; private List<Condition> conditions = Lists.newArrayList(); private List<Function> functions = Lists.newArrayList(); private boolean automatic = false; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v45/Migration45Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v45/Migration45Mapper.java index a6c41647f4c..046f01ec240 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v45/Migration45Mapper.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v45/Migration45Mapper.java @@ -19,10 +19,13 @@ */ package org.sonar.core.persistence.migration.v45; -import org.apache.ibatis.annotations.*; - import java.util.Date; import java.util.List; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Select; public interface Migration45Mapper { diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java index de2c16a78d2..d9b2fb55a78 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java @@ -20,10 +20,13 @@ package org.sonar.core.persistence.migration.v50; -import org.apache.ibatis.annotations.*; -import org.apache.ibatis.mapping.ResultSetType; - import java.util.List; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.mapping.ResultSetType; public interface Migration50Mapper { diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java index c66a963ba85..3996301bc7b 100644 --- a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java +++ b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java @@ -41,7 +41,8 @@ import org.sonar.api.utils.log.Profiler; public class ComponentContainer { // no need for multiple children - ComponentContainer parent, child; + ComponentContainer parent; + ComponentContainer child; MutablePicoContainer pico; PropertyDefinitions propertyDefinitions; ComponentKeys componentKeys; diff --git a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java index 008822ec40f..de3b7149eeb 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java +++ b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDto.java @@ -21,12 +21,14 @@ package org.sonar.core.qualitygate.db; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.sonar.api.measures.Metric.ValueType; - +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - -import java.util.*; +import org.sonar.api.measures.Metric.ValueType; /** * @since 4.3 @@ -46,39 +48,39 @@ public class QualityGateConditionDto { OPERATOR_GREATER_THAN, OPERATOR_EQUALS, OPERATOR_NOT_EQUALS - ); + ); private static final List<String> NUMERIC_OPERATORS = ImmutableList.of( - OPERATOR_LESS_THAN, - OPERATOR_GREATER_THAN, - OPERATOR_EQUALS, - OPERATOR_NOT_EQUALS - ); + OPERATOR_LESS_THAN, + OPERATOR_GREATER_THAN, + OPERATOR_EQUALS, + OPERATOR_NOT_EQUALS + ); private static final List<String> STRING_OPERATORS = ImmutableList.of( - OPERATOR_EQUALS, - OPERATOR_NOT_EQUALS, - OPERATOR_LESS_THAN, - OPERATOR_GREATER_THAN - ); + OPERATOR_EQUALS, + OPERATOR_NOT_EQUALS, + OPERATOR_LESS_THAN, + OPERATOR_GREATER_THAN + ); private static final List<String> LEVEL_OPERATORS = ImmutableList.of( OPERATOR_EQUALS, OPERATOR_NOT_EQUALS - ); + ); private static final List<String> BOOLEAN_OPERATORS = ImmutableList.of( OPERATOR_EQUALS - ); + ); private static final Map<ValueType, List<String>> OPERATORS_BY_TYPE = ImmutableMap.<ValueType, List<String>>builder() - .put(ValueType.BOOL, BOOLEAN_OPERATORS) - .put(ValueType.LEVEL, LEVEL_OPERATORS) - .put(ValueType.STRING, STRING_OPERATORS) - .put(ValueType.INT, NUMERIC_OPERATORS) - .put(ValueType.FLOAT, NUMERIC_OPERATORS) - .put(ValueType.PERCENT, NUMERIC_OPERATORS) - .put(ValueType.MILLISEC, NUMERIC_OPERATORS) - .put(ValueType.RATING, NUMERIC_OPERATORS) - .put(ValueType.WORK_DUR, NUMERIC_OPERATORS) - .build(); + .put(ValueType.BOOL, BOOLEAN_OPERATORS) + .put(ValueType.LEVEL, LEVEL_OPERATORS) + .put(ValueType.STRING, STRING_OPERATORS) + .put(ValueType.INT, NUMERIC_OPERATORS) + .put(ValueType.FLOAT, NUMERIC_OPERATORS) + .put(ValueType.PERCENT, NUMERIC_OPERATORS) + .put(ValueType.MILLISEC, NUMERIC_OPERATORS) + .put(ValueType.RATING, NUMERIC_OPERATORS) + .put(ValueType.WORK_DUR, NUMERIC_OPERATORS) + .build(); private long id; diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index bbfd1f0b863..ed79218f328 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -19,6 +19,13 @@ */ package org.sonar.core.rule; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -28,11 +35,6 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.core.persistence.Dto; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; - public class RuleDto extends Dto<RuleKey> { public static final Integer DISABLED_CHARACTERISTIC_ID = -1; diff --git a/sonar-core/src/main/java/org/sonar/core/user/DefaultUser.java b/sonar-core/src/main/java/org/sonar/core/user/DefaultUser.java index 09417ea9324..8d0fef42618 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/DefaultUser.java +++ b/sonar-core/src/main/java/org/sonar/core/user/DefaultUser.java @@ -31,7 +31,9 @@ import javax.annotation.Nullable; * @since 3.6 */ public class DefaultUser implements User { - private String login, name, email; + private String login; + private String name; + private String email; private boolean active; @Override diff --git a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java b/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java index 6ef4df804f6..ac14d44df45 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java +++ b/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java @@ -37,7 +37,7 @@ import javax.net.ssl.X509TrustManager; */ class HttpsTrust { - static HttpsTrust INSTANCE = new HttpsTrust(new Ssl()); + static final HttpsTrust INSTANCE = new HttpsTrust(new Ssl()); static class Ssl { SSLSocketFactory newFactory(TrustManager... managers) throws NoSuchAlgorithmException, KeyManagementException { diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java index fb07c08c09f..6c1973a9e66 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java +++ b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java @@ -21,14 +21,17 @@ package org.sonar.jpa.session; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.database.DatabaseSession; - +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import javax.persistence.EntityManager; import javax.persistence.NonUniqueResultException; import javax.persistence.PersistenceException; import javax.persistence.Query; -import java.util.*; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.database.DatabaseSession; public class JpaDatabaseSession extends DatabaseSession { @@ -239,7 +242,7 @@ public class JpaDatabaseSession extends DatabaseSession { } catch (NonUniqueResultException ex) { NonUniqueResultException e = new NonUniqueResultException("Expected single result for entitiy " + entityClass.getSimpleName() - + " with criterias : " + StringUtils.join(criterias, ",")); + + " with criterias : " + StringUtils.join(criterias, ",")); throw (NonUniqueResultException) e.initCause(ex); } } diff --git a/sonar-core/src/test/java/org/sonar/core/platform/ComponentContainerTest.java b/sonar-core/src/test/java/org/sonar/core/platform/ComponentContainerTest.java index 5d7923d23bd..2bb3b101e02 100644 --- a/sonar-core/src/test/java/org/sonar/core/platform/ComponentContainerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/platform/ComponentContainerTest.java @@ -322,7 +322,8 @@ public class ComponentContainerTest { } public static class StartableComponent { - public boolean started = false, stopped = false; + public boolean started = false; + public boolean stopped = false; public void start() { started = true; @@ -377,7 +378,9 @@ public class ComponentContainerTest { } public static class StartableCloseableComponent implements AutoCloseable { - public boolean isClosed = false, isStopped = false, isClosedAfterStop = false; + public boolean isClosed = false; + public boolean isStopped = false; + public boolean isClosedAfterStop = false; public void stop() { isStopped = true; diff --git a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java index 76ddb9f2c3d..e16ce16058f 100644 --- a/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/platform/PluginLoaderTest.java @@ -112,7 +112,9 @@ public class PluginLoaderTest { */ @Test public void test_plugins_sharing_the_same_classloader() throws Exception { - File baseJarFile = temp.newFile(), extensionJar1 = temp.newFile(), extensionJar2 = temp.newFile(); + File baseJarFile = temp.newFile(); + File extensionJar1 = temp.newFile(); + File extensionJar2 = temp.newFile(); PluginInfo base = new PluginInfo("foo") .setJarFile(baseJarFile) .setMainClass("org.foo.FooPlugin") diff --git a/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java index 1390d638c0b..b31d094e936 100644 --- a/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/user/AuthorizationDaoTest.java @@ -34,7 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class AuthorizationDaoTest extends AbstractDaoTestCase { private static final int USER = 100; - private static final Long PROJECT_ID = 300L, PROJECT_ID_WITHOUT_SNAPSHOT = 400L; + private static final Long PROJECT_ID = 300L; + private static final Long PROJECT_ID_WITHOUT_SNAPSHOT = 400L; private static final String PROJECT = "pj-w-snapshot"; private static final String PROJECT_WIHOUT_SNAPSHOT = "pj-wo-snapshot"; diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java index 9d93f9f0958..31440cf98c9 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/ContainsInComparator.java @@ -55,7 +55,8 @@ public final class ContainsInComparator implements Comparator<ClonePart> { } }; - private final int l1, l2; + private final int l1; + private final int l2; /** * Constructs new comparator for two parts with lengths {@code l1} and {@code l2} respectively. diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java index c6a95c9cae1..ac7cff51e8c 100644 --- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java +++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/suffixtree/Node.java @@ -45,7 +45,8 @@ public final class Node { */ int depth; - int startSize, endSize; + int startSize; + int endSize; public Node(Node node, Node suffixNode) { this(node.suffixTree, suffixNode); diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java index 3e83cd9d673..922a59e5e8d 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java @@ -34,7 +34,8 @@ public class FileCache { /** Maximum loop count when creating temp directories. */ private static final int TEMP_DIR_ATTEMPTS = 10000; - private final File dir, tmpDir; + private final File dir; + private final File tmpDir; private final FileHashes hashes; private final Logger logger; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java index 945f463721e..88f80180cc9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java @@ -19,17 +19,19 @@ */ package org.sonar.api.batch.bootstrap; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.CoreProperties; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.io.File; -import java.util.*; -import java.util.Map.Entry; - /** * Defines project metadata (key, name, source directories, ...). It's generally used by the * {@link org.sonar.api.batch.bootstrap.ProjectBuilder extension point} and must not be used diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java index bfe7b620828..b8b271e481d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultActiveRule.java @@ -31,7 +31,10 @@ import java.util.Map; public class DefaultActiveRule implements ActiveRule { private final RuleKey ruleKey; private final String name; - private final String severity, internalKey, language, templateRuleKey; + private final String severity; + private final String internalKey; + private final String language; + private final String templateRuleKey; private final Map<String, String> params; DefaultActiveRule(NewActiveRule newActiveRule) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java index db91ca70fe4..e2775a1ba4e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewActiveRule.java @@ -36,7 +36,9 @@ public class NewActiveRule { String name; String severity = Severity.defaultSeverity(); Map<String, String> params = new HashMap<>(); - String internalKey, language, templateRuleKey; + String internalKey; + String language; + String templateRuleKey; private final ActiveRulesBuilder builder; NewActiveRule(ActiveRulesBuilder builder, RuleKey ruleKey) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java index ff0e6aac38a..8aa9d38ac47 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java @@ -37,7 +37,9 @@ public class DefaultCoverage extends DefaultStorable implements NewCoverage { private DefaultInputFile inputFile; private CoverageType type; - private int totalCoveredLines = 0, totalConditions = 0, totalCoveredConditions = 0; + private int totalCoveredLines = 0; + private int totalConditions = 0; + private int totalCoveredConditions = 0; private SortedMap<Integer, Integer> hitsByLine = Maps.newTreeMap(); private SortedMap<Integer, Integer> conditionsByLine = Maps.newTreeMap(); private SortedMap<Integer, Integer> coveredConditionsByLine = Maps.newTreeMap(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java index 06e71528801..59f722246db 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java @@ -20,11 +20,15 @@ package org.sonar.api.measures; import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.SortedMap; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.utils.KeyValueFormat; -import java.util.*; - /** * @since 2.7 * @deprecated since 5.2 use {@link SensorContext#newCoverage()} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java index 78d6ea7b34f..c33d9e1d645 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java @@ -120,7 +120,8 @@ public class XMLProfileParser { while (rulesCursor.getNext() != null) { SMInputCursor ruleCursor = rulesCursor.childElementCursor(); - String repositoryKey = null, key = null; + String repositoryKey = null; + String key = null; RulePriority priority = null; parameters.clear(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java index e62752f3b72..7c23bc4734f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java @@ -32,7 +32,8 @@ import java.io.Serializable; public class RuleKey implements Serializable { public static final String MANUAL_REPOSITORY_KEY = "manual"; - private final String repository, rule; + private final String repository; + private final String rule; protected RuleKey(String repositoryKey, String ruleKey) { this.repository = repositoryKey; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java index 0b97f49695e..797833fad8b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/DefaultDebtRemediationFunctions.java @@ -33,7 +33,8 @@ import javax.annotation.Nullable; */ class DefaultDebtRemediationFunctions implements RulesDefinition.DebtRemediationFunctions { - private final String repoKey, key; + private final String repoKey; + private final String key; DefaultDebtRemediationFunctions(String repoKey, String key) { this.repoKey = repoKey; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 1c1aab3f78a..0c2919e3dc1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -505,7 +505,9 @@ public interface RulesDefinition { @Immutable class RepositoryImpl implements Repository { - private final String key, language, name; + private final String key; + private final String language; + private final String name; private final Map<String, Rule> rulesByKey; private RepositoryImpl(NewRepositoryImpl newRepository) { @@ -576,8 +578,13 @@ public interface RulesDefinition { } class NewRule { - private final String repoKey, key; - private String name, htmlDescription, markdownDescription, internalKey, severity = Severity.MAJOR; + private final String repoKey; + private final String key; + private String name; + private String htmlDescription; + private String markdownDescription; + private String internalKey; + private String severity = Severity.MAJOR; private boolean template; private RuleStatus status = RuleStatus.defaultStatus(); private String debtSubCharacteristic; @@ -787,7 +794,13 @@ public interface RulesDefinition { @Immutable class Rule { private final Repository repository; - private final String repoKey, key, name, htmlDescription, markdownDescription, internalKey, severity; + private final String repoKey; + private final String key; + private final String name; + private final String htmlDescription; + private final String markdownDescription; + private final String internalKey; + private final String severity; private final boolean template; private final String debtSubCharacteristic; private final DebtRemediationFunction debtRemediationFunction; @@ -915,7 +928,9 @@ public interface RulesDefinition { class NewParam { private final String key; - private String name, description, defaultValue; + private String name; + private String description; + private String defaultValue; private RuleParamType type = RuleParamType.STRING; private NewParam(String key) { @@ -956,7 +971,10 @@ public interface RulesDefinition { @Immutable class Param { - private final String key, name, description, defaultValue; + private final String key; + private final String name; + private final String description; + private final String defaultValue; private final RuleParamType type; private Param(NewParam newParam) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java index 0462fff23a2..20c85db7444 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java @@ -123,7 +123,12 @@ public class RulesDefinitionXmlLoader { } private void processRule(RulesDefinition.NewRepository repo, SMInputCursor ruleC) throws XMLStreamException { - String key = null, name = null, description = null, internalKey = null, severity = Severity.defaultSeverity(), status = null; + String key = null; + String name = null; + String description = null; + String internalKey = null; + String severity = Severity.defaultSeverity(); + String status = null; Cardinality cardinality = Cardinality.SINGLE; List<ParamStruct> params = new ArrayList<>(); List<String> tags = new ArrayList<>(); @@ -197,7 +202,9 @@ public class RulesDefinitionXmlLoader { } private static class ParamStruct { - String key, description, defaultValue; + String key; + String description; + String defaultValue; RuleParamType type = RuleParamType.STRING; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index 3f6654a6aaf..0c5c511c4ed 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -149,7 +149,8 @@ public interface WebService extends Definable<WebService.Context> { class NewController { private final Context context; private final String path; - private String description, since; + private String description; + private String since; private final Map<String, NewAction> actions = Maps.newHashMap(); private NewController(Context context, String path) { @@ -200,7 +201,9 @@ public interface WebService extends Definable<WebService.Context> { @Immutable class Controller { - private final String path, description, since; + private final String path; + private final String description; + private final String since; private final Map<String, Action> actions; private Controller(NewController newController) { @@ -259,8 +262,11 @@ public interface WebService extends Definable<WebService.Context> { class NewAction { private final String key; - private String deprecatedKey, description, since; - private boolean post = false, isInternal = false; + private String deprecatedKey; + private String description; + private String since; + private boolean post = false; + private boolean isInternal = false; private RequestHandler handler; private Map<String, NewParam> newParams = Maps.newHashMap(); private URL responseExample = null; @@ -408,8 +414,13 @@ public interface WebService extends Definable<WebService.Context> { @Immutable class Action { - private final String key, deprecatedKey, path, description, since; - private final boolean post, isInternal; + private final String key; + private final String deprecatedKey; + private final String path; + private final String description; + private final String since; + private final boolean post; + private final boolean isInternal; private final RequestHandler handler; private final Map<String, Param> params; private final URL responseExample; @@ -523,7 +534,11 @@ public interface WebService extends Definable<WebService.Context> { } class NewParam { - private String key, deprecatedKey, description, exampleValue, defaultValue; + private String key; + private String deprecatedKey; + private String description; + private String exampleValue; + private String defaultValue; private boolean required = false; private Set<String> possibleValues = null; @@ -652,7 +667,11 @@ public interface WebService extends Definable<WebService.Context> { public static final String FACETS = "facets"; public static final String SELECTED = "selected"; - private final String key, deprecatedKey, description, exampleValue, defaultValue; + private final String key; + private final String deprecatedKey; + private final String description; + private final String exampleValue; + private final String defaultValue; private final boolean required; private final Set<String> possibleValues; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java index d008af88621..cd28a959320 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java @@ -64,7 +64,9 @@ public class Duration implements Serializable { * For instance, Duration.decode("1d 1h", 8) will have a number of minutes of 540 (1*8*60 + 60). * */ public static Duration decode(String text, int hoursInDay) { - int days = 0, hours = 0, minutes = 0; + int days = 0; + int hours = 0; + int minutes = 0; String sanitizedText = StringUtils.deleteWhitespace(text); Pattern pattern = Pattern.compile("\\s*+(?:(\\d++)\\s*+" + DAY + ")?+\\s*+(?:(\\d++)\\s*+" + HOUR + ")?+\\s*+(?:(\\d++)\\s*+" + MINUTE + ")?+\\s*+"); Matcher matcher = pattern.matcher(text); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java index 7f4e946686c..7d442c3d25e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java @@ -77,7 +77,9 @@ public class WorkDuration implements Serializable { } static WorkDuration createFromLong(long duration, int hoursInDay) { - int days = 0, hours = 0, minutes = 0; + int days = 0; + int hours = 0; + int minutes = 0; long time = duration; Long currentTime = time / WorkDuration.DAY_POSITION_IN_LONG; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/CsvWriter.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/CsvWriter.java index 0cb824a142d..3cd050285fc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/CsvWriter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/CsvWriter.java @@ -30,7 +30,8 @@ import java.io.Writer; public class CsvWriter { private final Writer writer; - private static final String VALUE_SEPARATOR = ",", LINE_SEPARATOR = "\r\n"; + private static final String VALUE_SEPARATOR = ","; + private static final String LINE_SEPARATOR = "\r\n"; private CsvWriter(Writer writer) { this.writer = writer; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java index 60169f69f6e..5e9d1bcbdbb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetScope.java @@ -19,7 +19,10 @@ */ package org.sonar.api.web; -import java.lang.annotation.*; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Depending on its scope, a widget can be available for project dashboards <code>(value = "PROJECT")</code>, diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java index 1e48ebf494e..2bf8848c445 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java @@ -19,7 +19,9 @@ */ package org.sonar.api.checks; -import org.sonar.check.*; +import org.sonar.check.Priority; +import org.sonar.check.Rule; +import org.sonar.check.RuleProperty; @Rule(priority = Priority.CRITICAL) class CheckWithIntegerProperty { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java index 6e1b4fc01a6..1acd5f0b56c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/WebServiceTest.java @@ -36,7 +36,8 @@ import static org.mockito.Mockito.mock; public class WebServiceTest { static class MetricWs implements WebService { - boolean showCalled = false, createCalled = false; + boolean showCalled = false; + boolean createCalled = false; @Override public void define(Context context) { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/CsvWriterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/CsvWriterTest.java index aed9cfb6f48..7bdd5125893 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/CsvWriterTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/CsvWriterTest.java @@ -19,10 +19,13 @@ */ package org.sonar.api.utils.text; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; import org.junit.Test; -import java.io.*; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyString; |