diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-04-12 14:13:56 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-04-12 16:39:56 +0200 |
commit | 2f5d9eaccf74c99481b284a2a30016fe600978fc (patch) | |
tree | ec4dd3ac31ca6a1748326e3f10d77d2a3adf8045 /sonar-scanner-engine/src | |
parent | 7b341707990b0ab9ab1c51cf19a7675af9507578 (diff) | |
download | sonarqube-2f5d9eaccf74c99481b284a2a30016fe600978fc.tar.gz sonarqube-2f5d9eaccf74c99481b284a2a30016fe600978fc.zip |
Fix Quality flaws
Diffstat (limited to 'sonar-scanner-engine/src')
3 files changed, 15 insertions, 24 deletions
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. |