]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 20 Apr 2015 08:26:03 +0000 (10:26 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 20 Apr 2015 08:26:19 +0000 (10:26 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java

index 974a5678a497b3edc61e2328d99ca13878b4bf9d..7bae33f27d4c13e85a1038b0b7c2936607959399 100644 (file)
@@ -173,8 +173,8 @@ public class PersistFileSourcesStep implements ComputationStep {
   }
 
   private static class LineReaders {
-    private final List<LineReader> lineReaders = new ArrayList<>();
-    private final List<ReportIterator> reportIterators = new ArrayList<>();
+    private final List<LineReader> readers = new ArrayList<>();
+    private final List<ReportIterator> iterators = new ArrayList<>();
 
     LineReaders(BatchReportReader reportReader, int componentRef) {
       File coverageFile = reportReader.readComponentCoverage(componentRef);
@@ -185,31 +185,31 @@ public class PersistFileSourcesStep implements ComputationStep {
 
       if (coverageFile != null) {
         ReportIterator<BatchReport.Coverage> coverageReportIterator = new ReportIterator<>(coverageFile, BatchReport.Coverage.PARSER);
-        reportIterators.add(coverageReportIterator);
-        lineReaders.add(new CoverageLineReader(coverageReportIterator));
+        iterators.add(coverageReportIterator);
+        readers.add(new CoverageLineReader(coverageReportIterator));
       }
       if (scmReport != null) {
-        lineReaders.add(new ScmLineReader(scmReport));
+        readers.add(new ScmLineReader(scmReport));
       }
       if (highlightingFile != null) {
         ReportIterator<BatchReport.SyntaxHighlighting> syntaxHighlightingReportIterator = new ReportIterator<>(highlightingFile, BatchReport.SyntaxHighlighting.PARSER);
-        reportIterators.add(syntaxHighlightingReportIterator);
-        lineReaders.add(new HighlightingLineReader(syntaxHighlightingReportIterator));
+        iterators.add(syntaxHighlightingReportIterator);
+        readers.add(new HighlightingLineReader(syntaxHighlightingReportIterator));
       }
       if (!duplications.isEmpty()) {
-        lineReaders.add(new DuplicationLineReader(duplications));
+        readers.add(new DuplicationLineReader(duplications));
       }
       if (!symbols.isEmpty()) {
-        lineReaders.add(new SymbolsLineReader(symbols));
+        readers.add(new SymbolsLineReader(symbols));
       }
     }
 
     List<LineReader> readers() {
-      return lineReaders;
+      return readers;
     }
 
     void close() {
-      for (ReportIterator reportIterator : reportIterators) {
+      for (ReportIterator reportIterator : iterators) {
         reportIterator.close();
       }
     }
index b98a7c9f09d451bbc2323440ba37222834656fbb..ac5242da4cbe86fb527c25b501742910af09af26 100644 (file)
@@ -29,6 +29,8 @@ import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.process.ProcessProperties;
 
+import javax.annotation.CheckForNull;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -66,24 +68,24 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable {
   @Override
   public void start() {
     LOGGER.info("SonarQube home: " + homeDir.getAbsolutePath());
+
+    File deployDir = getDeployDir();
+    if (deployDir == null) {
+      throw new IllegalArgumentException("Web app directory does not exist: " + getDeployDir());
+    }
     try {
-      if (getDeployDir() == null) {
-        throw new IllegalArgumentException("Web app directory does not exist: " + getDeployDir());
-      }
-      FileUtils.forceMkdir(getDeployDir());
-      for (File subDirectory : getDeployDir().listFiles((FileFilter) FileFilterUtils.directoryFileFilter())) {
+      FileUtils.forceMkdir(deployDir);
+      for (File subDirectory : deployDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())) {
         FileUtils.cleanDirectory(subDirectory);
       }
-
     } catch (IOException e) {
-      throw new IllegalStateException("The following directory can not be created: " + getDeployDir().getAbsolutePath(), e);
+      throw new IllegalStateException("The following directory can not be created: " + deployDir.getAbsolutePath(), e);
     }
 
     File deprecated = getDeprecatedPluginsDir();
     try {
       FileUtils.forceMkdir(deprecated);
       FileUtils.cleanDirectory(deprecated);
-
     } catch (IOException e) {
       throw new IllegalStateException("The following directory can not be created: " + deprecated.getAbsolutePath(), e);
     }
@@ -104,6 +106,7 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable {
     return tempDir;
   }
 
+  @CheckForNull
   public File getDeployDir() {
     return server.getDeployDir();
   }
index dd961e8c560aa50e4008bfc9cc23eaa061fca916..bae47f5e2fcededd7f3fb0dd23d79be7fb447902 100644 (file)
@@ -33,6 +33,8 @@ import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.process.ProcessProperties;
 
+import javax.annotation.CheckForNull;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -127,6 +129,7 @@ public final class ServerImpl extends Server implements Startable {
   }
 
   @Override
+  @CheckForNull
   public File getDeployDir() {
     return deployDir;
   }
index 8907b3e6d5d08d1a70c7c4d645f84cc8cac574c1..aaada9f9131a7bd5893ca702840fc0db81fd98c5 100644 (file)
@@ -25,10 +25,14 @@ import org.sonar.api.platform.Server;
 import org.sonar.api.platform.ServerStartHandler;
 import org.sonar.api.platform.ServerStopHandler;
 
+import javax.annotation.CheckForNull;
+
 import java.io.File;
 import java.util.Date;
 
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
 
 public class ServerLifecycleNotifierTest {
 
@@ -106,6 +110,7 @@ class FakeServer extends Server {
   }
 
   @Override
+  @CheckForNull
   public File getDeployDir() {
     return null;
   }
index 4c18063f5743d5d20e8b1ce475ce9f13f6599b63..662d5bd9a1eae98401d817e5fa9aa4f46aff83de 100644 (file)
  */
 package org.sonar.batch.platform;
 
-import org.sonar.batch.bootstrap.ServerClient;
-
 import org.slf4j.LoggerFactory;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
 import org.sonar.api.platform.Server;
+import org.sonar.batch.bootstrap.ServerClient;
+
+import javax.annotation.CheckForNull;
 
 import java.io.File;
 import java.text.ParseException;
@@ -72,6 +73,7 @@ public class DefaultServer extends Server implements BatchComponent {
   }
 
   @Override
+  @CheckForNull
   public File getDeployDir() {
     return null;
   }
index 7fd8afd1b1ed9e51e8cf7f994af0cf30c37d95d2..4f4502779ab034a5e017e0e918d4bc1d927cfaae 100644 (file)
@@ -22,6 +22,8 @@ package org.sonar.api.platform;
 import org.sonar.api.BatchComponent;
 import org.sonar.api.ServerComponent;
 
+import javax.annotation.CheckForNull;
+
 import java.io.File;
 import java.util.Date;
 
@@ -38,6 +40,7 @@ public abstract class Server implements BatchComponent, ServerComponent {
 
   public abstract File getRootDir();
 
+  @CheckForNull
   public abstract File getDeployDir();
 
   public abstract String getContextPath();