aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-02-20 22:30:43 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-02-20 22:30:43 +0100
commit22dfc24e49896cfa4c77e11a0e60e67c21f6db33 (patch)
tree19ed694f064008333147a9edc37253229cd45f40 /sonar-testing-harness
parent726c17ed044d5e23a4ee1465a8a8c487ac1a9646 (diff)
downloadsonarqube-22dfc24e49896cfa4c77e11a0e60e67c21f6db33.tar.gz
sonarqube-22dfc24e49896cfa4c77e11a0e60e67c21f6db33.zip
Fix some quality flaws, particularly on newly inspected code
Diffstat (limited to 'sonar-testing-harness')
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
index 853365c3bcf..93aecf2c1d6 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
@@ -29,7 +29,10 @@ import org.sonar.test.TestUtils;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.*;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+import java.util.SortedMap;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@@ -41,7 +44,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
public static final String L10N_PATH = "/org/sonar/l10n/";
private static final String GITHUB_RAW_FILE_PATH = "https://raw.github.com/SonarSource/sonar/master/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/";
private static final Collection<String> CORE_BUNDLES = Lists.newArrayList("checkstyle.properties", "core.properties",
- "findbugs.properties", "gwt.properties", "pmd.properties", "squidjava.properties");
+ "findbugs.properties", "gwt.properties", "pmd.properties", "squidjava.properties");
private String sonarVersion;
// we use this variable to be able to unit test this class without looking at the real Github core bundles that change all the time
@@ -157,7 +160,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
try {
props.load(input);
return props;
-
+
} finally {
IOUtils.closeQuietly(input);
}
@@ -196,7 +199,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
protected String extractDefaultBundleName(String bundleName) {
int firstUnderScoreIndex = bundleName.indexOf('_');
assertThat("The bundle '" + bundleName + "' is a default bundle (without locale), so it can't be compared.", firstUnderScoreIndex > 0,
- is(true));
+ is(true));
return bundleName.substring(0, firstUnderScoreIndex) + ".properties";
}
@@ -204,14 +207,14 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
return CORE_BUNDLES.contains(defaultBundleName);
}
- private void saveUrlToLocalFile(String url, File localFile) throws MalformedURLException, IOException {
+ private void saveUrlToLocalFile(String url, File localFile) throws IOException {
if (localFile.exists()) {
localFile.delete();
}
localFile.getParentFile().mkdirs();
- BufferedInputStream in = null;
- FileOutputStream fout = null;
+ InputStream in = null;
+ OutputStream fout = null;
try {
in = new BufferedInputStream(new URL(url).openStream());
fout = new FileOutputStream(localFile);
@@ -222,10 +225,8 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
fout.write(data, 0, count);
}
} finally {
- if (in != null)
- in.close();
- if (fout != null)
- fout.close();
+ IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(fout);
}
}