From 501289ca85e1c8dd21d5e0ba5f457b40ee62f5ef Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 29 Jun 2015 15:53:56 +0200 Subject: Quality flaws - do not declare multiple variables on same line - fix imports --- .../api/batch/bootstrap/ProjectDefinition.java | 16 +++++----- .../api/batch/rule/internal/DefaultActiveRule.java | 5 +++- .../api/batch/rule/internal/NewActiveRule.java | 4 ++- .../sensor/coverage/internal/DefaultCoverage.java | 4 ++- .../api/measures/CoverageMeasuresBuilder.java | 8 +++-- .../org/sonar/api/profiles/XMLProfileParser.java | 3 +- .../src/main/java/org/sonar/api/rule/RuleKey.java | 3 +- .../rule/DefaultDebtRemediationFunctions.java | 3 +- .../org/sonar/api/server/rule/RulesDefinition.java | 30 +++++++++++++++---- .../api/server/rule/RulesDefinitionXmlLoader.java | 11 +++++-- .../java/org/sonar/api/server/ws/WebService.java | 35 +++++++++++++++++----- .../main/java/org/sonar/api/utils/Duration.java | 4 ++- .../org/sonar/api/utils/internal/WorkDuration.java | 4 ++- .../java/org/sonar/api/utils/text/CsvWriter.java | 3 +- .../main/java/org/sonar/api/web/WidgetScope.java | 5 +++- .../sonar/api/checks/CheckWithIntegerProperty.java | 4 ++- .../org/sonar/api/server/ws/WebServiceTest.java | 3 +- .../org/sonar/api/utils/text/CsvWriterTest.java | 7 +++-- 18 files changed, 113 insertions(+), 39 deletions(-) (limited to 'sonar-plugin-api') 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 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 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 hitsByLine = Maps.newTreeMap(); private SortedMap conditionsByLine = Maps.newTreeMap(); private SortedMap 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 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 params = new ArrayList<>(); List 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 { class NewController { private final Context context; private final String path; - private String description, since; + private String description; + private String since; private final Map actions = Maps.newHashMap(); private NewController(Context context, String path) { @@ -200,7 +201,9 @@ public interface WebService extends Definable { @Immutable class Controller { - private final String path, description, since; + private final String path; + private final String description; + private final String since; private final Map actions; private Controller(NewController newController) { @@ -259,8 +262,11 @@ public interface WebService extends Definable { 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 newParams = Maps.newHashMap(); private URL responseExample = null; @@ -408,8 +414,13 @@ public interface WebService extends Definable { @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 params; private final URL responseExample; @@ -523,7 +534,11 @@ public interface WebService extends Definable { } 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 possibleValues = null; @@ -652,7 +667,11 @@ public interface WebService extends Definable { 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 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 (value = "PROJECT"), 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; -- cgit v1.2.3