aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-04-20 10:26:03 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-04-20 10:26:19 +0200
commit9f8719eeeb9aac242b932861400b287e1b1cf0d3 (patch)
treef637ddd4ca62851b9aa2cd2799ae994bee5a55da /server
parenta789df43e7384d15edb21ebfe978bbd12be63cdc (diff)
downloadsonarqube-9f8719eeeb9aac242b932861400b287e1b1cf0d3.tar.gz
sonarqube-9f8719eeeb9aac242b932861400b287e1b1cf0d3.zip
Fix quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java22
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java19
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java7
4 files changed, 31 insertions, 20 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
index 974a5678a49..7bae33f27d4 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
@@ -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();
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
index b98a7c9f09d..ac5242da4cb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java
@@ -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();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
index dd961e8c560..bae47f5e2fc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
@@ -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;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
index 8907b3e6d5d..aaada9f9131 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
@@ -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;
}