diff options
12 files changed, 26 insertions, 69 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java index 8a81d3cfdf2..2119ca6a263 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/ProjectMeasuresIndexerIterator.java @@ -84,7 +84,7 @@ public class ProjectMeasuresIndexerIterator extends CloseableIterator<ProjectMea private final Map<Long, String> metricKeysByIds; private final Iterator<Project> projects; - private ProjectMeasuresIndexerIterator(PreparedStatement measuresStatement, Map<Long, String> metricKeysByIds, List<Project> projects) throws SQLException { + private ProjectMeasuresIndexerIterator(PreparedStatement measuresStatement, Map<Long, String> metricKeysByIds, List<Project> projects) { this.measuresStatement = measuresStatement; this.metricKeysByIds = metricKeysByIds; this.projects = projects.iterator(); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleKey.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleKey.java index 299493bd9f6..d015649fead 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleKey.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleKey.java @@ -84,10 +84,7 @@ public class ActiveRuleKey implements Serializable, Comparable<ActiveRuleKey> { if (!qualityProfileKey.equals(activeRuleKey.qualityProfileKey)) { return false; } - if (!ruleKey.equals(activeRuleKey.ruleKey)) { - return false; - } - return true; + return ruleKey.equals(activeRuleKey.ruleKey); } @Override diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java index a55209ac99c..d700bd8df6c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java @@ -44,14 +44,6 @@ public class QualityProfileDto extends Dto<String> { private Long userUpdatedAt; private boolean isDefault; - /** - * @deprecated use {@link #createFor(String)} - */ - @Deprecated - public QualityProfileDto() { - - } - public String getOrganizationUuid() { return organizationUuid; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleService.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleService.java index 2cf38376560..4e86137dacf 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleService.java @@ -41,10 +41,6 @@ public class RuleService { this.index = index; } - public RuleQuery newRuleQuery() { - return new RuleQuery(); - } - /** * List all tags, including system tags, defined on rules */ diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleQuery.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleQuery.java index b3d67dc4a11..92bc3f44f67 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleQuery.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleQuery.java @@ -51,14 +51,6 @@ public class RuleQuery { private String internalKey; private String ruleKey; - /** - * TODO should not be public - * - * @see org.sonar.server.rule.RuleService#newRuleQuery() - */ - public RuleQuery() { - } - @CheckForNull public String getQProfileKey() { return qProfileKey; diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java index edb08e8bf25..9a1a2c3e5dc 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java @@ -45,10 +45,6 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder { private RuleType type; private Map<String, String> attributes; - public DefaultIssueBuilder() { - - } - public DefaultIssueBuilder componentKey(String componentKey) { this.componentKey = componentKey; return this; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java b/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java index bbd27c3ecb9..5674f365e62 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java @@ -19,8 +19,6 @@ */ package org.sonar.api.security; -import com.google.common.base.MoreObjects; - /** * This class is not intended to be subclassed by clients. * @@ -33,9 +31,6 @@ public final class UserDetails { private String email = ""; private String userId = ""; - public UserDetails() { - } - public void setEmail(String email) { this.email = email; } @@ -68,10 +63,11 @@ public final class UserDetails { @Override public String toString() { - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("email", email) - .add("userId", userId) - .toString(); + StringBuilder sb = new StringBuilder("UserDetails{"); + sb.append("name='").append(name).append('\''); + sb.append(", email='").append(email).append('\''); + sb.append(", userId='").append(userId).append('\''); + sb.append('}'); + return sb.toString(); } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/security/UserDetailsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/security/UserDetailsTest.java index 95089e4c01c..3c0a6a2da59 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/security/UserDetailsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/security/UserDetailsTest.java @@ -74,6 +74,6 @@ public class UserDetailsTest { userDetails.setEmail("foo@example.com"); userDetails.setUserId("foo@example"); - assertThat(userDetails.toString()).isEqualTo("UserDetails{name=foo, email=foo@example.com, userId=foo@example}"); + assertThat(userDetails.toString()).isEqualTo("UserDetails{name='foo', email='foo@example.com', userId='foo@example'}"); } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java index 5a89d11e5d5..3f6656e5cd0 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java @@ -19,7 +19,6 @@ */ package org.sonar.scanner.rule; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -57,19 +56,15 @@ public class ActiveRulesProvider extends ProviderAdapter { Collection<String> qProfileKeys = getKeys(qProfiles); Map<RuleKey, LoadedActiveRule> loadedRulesByKey = new HashMap<>(); - try { - for (String qProfileKey : qProfileKeys) { - Collection<LoadedActiveRule> qProfileRules; - qProfileRules = load(loader, qProfileKey); + for (String qProfileKey : qProfileKeys) { + Collection<LoadedActiveRule> qProfileRules; + qProfileRules = load(loader, qProfileKey); - for (LoadedActiveRule r : qProfileRules) { - if (!loadedRulesByKey.containsKey(r.getRuleKey())) { - loadedRulesByKey.put(r.getRuleKey(), r); - } + for (LoadedActiveRule r : qProfileRules) { + if (!loadedRulesByKey.containsKey(r.getRuleKey())) { + loadedRulesByKey.put(r.getRuleKey(), r); } } - } catch (IOException e) { - throw new IllegalStateException("Error loading active rules", e); } return transform(loadedRulesByKey.values()); @@ -99,7 +94,7 @@ public class ActiveRulesProvider extends ProviderAdapter { return builder.build(); } - private static List<LoadedActiveRule> load(ActiveRulesLoader loader, String qProfileKey) throws IOException { + private static List<LoadedActiveRule> load(ActiveRulesLoader loader, String qProfileKey) { return loader.load(qProfileKey); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/HtmlReport.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/HtmlReport.java index 4580b7421ad..4be0a717108 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/HtmlReport.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/HtmlReport.java @@ -28,7 +28,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; -import java.net.URISyntaxException; import java.util.Map; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -145,7 +144,7 @@ public class HtmlReport implements Reporter { } } - void copyDependencies(File toDir) throws URISyntaxException, IOException { + private void copyDependencies(File toDir) throws IOException { File target = new File(toDir, "issuesreport_files"); FileUtils.forceMkdir(target); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java index 7db8f84929a..c7079a019ce 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java @@ -120,13 +120,10 @@ public class JSONReport implements Reporter { writeJsonRules(json, ruleKeys); writeUsers(json, userLogins); json.endObject(); - - } catch (IOException e) { - throw new IllegalStateException("Unable to write JSON report", e); } } - private void writeJsonIssues(JsonWriter json, Set<RuleKey> ruleKeys, Set<String> logins) throws IOException { + private void writeJsonIssues(JsonWriter json, Set<RuleKey> ruleKeys, Set<String> logins) { json.name("issues").beginArray(); for (TrackedIssue issue : getIssues()) { if (issue.resolution() == null) { @@ -166,14 +163,14 @@ public class JSONReport implements Reporter { private DefaultInputModule getModule(InputComponent component) { if (component.isFile()) { return (DefaultInputModule) inputComponentTree.getParent(inputComponentTree.getParent(component)); - } else if (component instanceof InputDir) { + } + if (component instanceof InputDir) { return (DefaultInputModule) inputComponentTree.getParent(component); - } else { - return (DefaultInputModule) component; } + return (DefaultInputModule) component; } - private void writeJsonComponents(JsonWriter json) throws IOException { + private void writeJsonComponents(JsonWriter json) { json.name("components").beginArray(); // Dump modules writeJsonModuleComponents(json, rootModule); @@ -213,7 +210,7 @@ public class JSONReport implements Reporter { } } - private void writeJsonRules(JsonWriter json, Set<RuleKey> ruleKeys) throws IOException { + private void writeJsonRules(JsonWriter json, Set<RuleKey> ruleKeys) { json.name("rules").beginArray(); for (RuleKey ruleKey : ruleKeys) { json @@ -227,7 +224,7 @@ public class JSONReport implements Reporter { json.endArray(); } - private static void writeUsers(JsonWriter json, Collection<String> userLogins) throws IOException { + private static void writeUsers(JsonWriter json, Collection<String> userLogins) { json.name("users").beginArray(); // for compatiblity with programs that parse the json report. We no longer get the name for logins. diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java index af05fd103ac..c2cc0922f2b 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java @@ -175,10 +175,7 @@ class JsonComparison { return false; } } - if (!remainingActual.isEmpty()) { - return false; - } - return true; + return remainingActual.isEmpty(); } private boolean compareObjects(JSONObject expectedMap, JSONObject actualMap) { @@ -203,7 +200,7 @@ class JsonComparison { } @CheckForNull - static Date tryParseDate(String s) { + private static Date tryParseDate(String s) { try { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(s); } catch (ParseException ignored) { |