]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 30 Jun 2015 08:39:54 +0000 (10:39 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 30 Jun 2015 08:40:57 +0000 (10:40 +0200)
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/TempFolderProvider.java
sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java

index 3cc0cbe5a7f39d4e20fb385ba7cdba9ff4431903..13860cdbaba35ca90458a238d1f9516685cb9379 100644 (file)
@@ -291,8 +291,9 @@ public class SearchAction implements IssuesWsAction {
   }
 
   private void writeResponse(Request request, SearchResult<IssueDoc> result, JsonWriter json) {
-    if (result.getFacets().contains(IssueIndex.DEBT_AGGREGATION_NAME)) {
-      json.prop("debtTotal", result.getFacets().get(IssueIndex.DEBT_AGGREGATION_NAME).get(Facets.TOTAL));
+    Map<String, Long> debtFacet = result.getFacets().get(IssueIndex.DEBT_AGGREGATION_NAME);
+    if (debtFacet != null) {
+      json.prop("debtTotal", debtFacet.get(Facets.TOTAL));
     }
 
     List<String> issueKeys = newArrayList();
index 175009bd898e020c3280d884ff6da551dedd496a..9b4d199df837f06aa00fa6dc1db5ea2f7c6e9419 100644 (file)
@@ -67,7 +67,7 @@ public class TempFolderProvider extends LifecycleProviderAdapter {
       try {
         cleanTempFolders(workingPath);
       } catch (IOException e) {
-        LOG.warn("failed to clean global working directory: " + e.getMessage());
+        LOG.error(String.format("failed to clean global working directory: %s", workingPath), e);
       }
 
       Path tempDir = workingPath.resolve(TMP_NAME_PREFIX + System.currentTimeMillis());
@@ -110,12 +110,12 @@ public class TempFolderProvider extends LifecycleProviderAdapter {
 
   private static class CleanFilter implements DirectoryStream.Filter<Path> {
     @Override
-    public boolean accept(Path e) throws IOException {
-      if (!Files.isDirectory(e)) {
+    public boolean accept(Path path) throws IOException {
+      if (!Files.isDirectory(path)) {
         return false;
       }
 
-      if (!e.getFileName().toString().startsWith(TMP_NAME_PREFIX)) {
+      if (!path.getFileName().toString().startsWith(TMP_NAME_PREFIX)) {
         return false;
       }
 
@@ -125,9 +125,9 @@ public class TempFolderProvider extends LifecycleProviderAdapter {
       BasicFileAttributes attrs;
 
       try {
-        attrs = Files.readAttributes(e, BasicFileAttributes.class);
+        attrs = Files.readAttributes(path, BasicFileAttributes.class);
       } catch (IOException ioe) {
-        LOG.warn("couldn't read file attributes for " + e + " : " + ioe.getMessage());
+        LOG.error(String.format("Couldn't read file attributes for %s : ", path), ioe);
         return false;
       }
 
index 360685bec9ba57b17b67b57d72bcaba7cdb8705a..b681961f83d37d79292c1ee30766299128461b9b 100644 (file)
@@ -56,7 +56,7 @@ public final class I18nMatchers {
     }
 
     Collection<File> bundles = FileUtils.listFiles(bundleFolder, new String[]{"properties"}, false);
-    Map<String, String> failedAssertionMessages = new HashMap();
+    Map<String, String> failedAssertionMessages = new HashMap<>();
     for (File bundle : bundles) {
       String bundleName = bundle.getName();
       if (bundleName.indexOf('_') > 0) {