aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-11-10 17:12:59 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-11-11 10:50:53 +0100
commit1bee96aec33f4fa92c82a2d4359ae47e9b42a51a (patch)
tree9b2c03de49a93fcaa71c4e63e3aa127e8bc1f2a1 /sonar-batch
parent3e019c0afb4a3df57ed86fe394a090b75f2d7218 (diff)
downloadsonarqube-1bee96aec33f4fa92c82a2d4359ae47e9b42a51a.tar.gz
sonarqube-1bee96aec33f4fa92c82a2d4359ae47e9b42a51a.zip
Improve quality
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java28
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java2
5 files changed, 16 insertions, 24 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java b/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
index 5845469dcf9..13845f0808e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/WSLoader.java
@@ -122,7 +122,7 @@ public class WSLoader {
}
private int getReadTimeout() {
- return userProperties.properties().containsKey(SONAR_WS_TIMEOUT_PROPS) ? Integer.parseInt(userProperties.property(SONAR_WS_TIMEOUT_PROPS)) * 1000 : DEFAULT_READ_TIMEOUT;
+ return userProperties.properties().containsKey(SONAR_WS_TIMEOUT_PROPS) ? (Integer.parseInt(userProperties.property(SONAR_WS_TIMEOUT_PROPS)) * 1000) : DEFAULT_READ_TIMEOUT;
}
@Nonnull
@@ -221,7 +221,7 @@ public class WSLoader {
if (result == null) {
throw new NotAvailableException("resource not cached");
}
- return new WSLoaderResult<T>(result, true);
+ return new WSLoaderResult<>(result, true);
}
@Nonnull
@@ -232,7 +232,7 @@ public class WSLoader {
try {
T t = loader.load(id);
switchToOnline();
- return new WSLoaderResult<T>(t, false);
+ return new WSLoaderResult<>(t, false);
} catch (IllegalStateException e) {
if (e.getCause() instanceof HttpException) {
// fail fast if it could connect but there was a application-level error
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
index 3776236ae1e..575df94cd5f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
@@ -107,7 +107,7 @@ public class TrackedIssueAdapter implements Issue {
@Override
public Date creationDate() {
- return null;
+ return issue.getCreationDate();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java
index 0f2d528a49c..8215cba4b29 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java
@@ -61,7 +61,7 @@ public class QProfileSensor implements Sensor {
used.add(profile);
}
}
- Measure<?> detailsMeasure = new Measure<String>(CoreMetrics.QUALITY_PROFILES, used.toJson());
+ Measure<?> detailsMeasure = new Measure<>(CoreMetrics.QUALITY_PROFILES, used.toJson());
context.saveMeasure(detailsMeasure);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
index ad73100f467..f57c5db36f9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
@@ -53,9 +53,9 @@ import org.sonar.api.utils.MessageException;
*/
public class DefaultModuleFileSystem extends DefaultFileSystem implements ModuleFileSystem {
- private final String moduleKey;
- private final FileIndexer indexer;
- private final Settings settings;
+ private String moduleKey;
+ private FileIndexer indexer;
+ private Settings settings;
private File buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
@@ -67,26 +67,18 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project project,
Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer, DefaultAnalysisMode mode) {
super(initializer.baseDir(), moduleInputFileCache);
- this.componentIndexer = componentIndexer;
- this.moduleKey = project.getKey();
- this.settings = settings;
- this.indexer = indexer;
- setWorkDir(initializer.workingDir());
- this.buildDir = initializer.buildDir();
- this.sourceDirsOrFiles = initializer.sources();
- this.testDirsOrFiles = initializer.tests();
- this.binaryDirs = initializer.binaryDirs();
-
- // filter the files that sensors have access to (SONAR-6931)
- if (!mode.scanAllFiles()) {
- setDefaultPredicate(predicates.not(predicates.hasStatus(Status.SAME)));
- }
+ setFields(project, settings, indexer, initializer, componentIndexer, mode);
}
@VisibleForTesting
public DefaultModuleFileSystem(Project project,
Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer, DefaultAnalysisMode mode) {
super(initializer.baseDir().toPath());
+ setFields(project, settings, indexer, initializer, componentIndexer, mode);
+ }
+
+ private void setFields(Project project,
+ Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer, DefaultAnalysisMode mode) {
this.componentIndexer = componentIndexer;
this.moduleKey = project.getKey();
this.settings = settings;
@@ -96,7 +88,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
this.binaryDirs = initializer.binaryDirs();
-
+
// filter the files sensors have access to
if (!mode.scanAllFiles()) {
setDefaultPredicate(predicates.not(predicates.hasStatus(Status.SAME)));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
index f7cd9bf6e0b..6f7965fa069 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
@@ -219,7 +219,7 @@ public class JSONReport implements Reporter {
}
private void writeUsers(JsonWriter json, Collection<String> userLogins) throws IOException {
- List<BatchInput.User> users = new LinkedList<BatchInput.User>();
+ List<BatchInput.User> users = new LinkedList<>();
for (String userLogin : userLogins) {
User user = userRepository.load(userLogin);
if (user != null) {