aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-06 10:29:10 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-12 16:12:49 +0200
commit644141e706e864f304edbd9b50762d7e005bf9a9 (patch)
treea2c7146f779ac8be649b4b0442598f978547e3aa /sonar-batch
parentf14a07796a04815dabde6f357de3ac87e5344d4a (diff)
downloadsonarqube-644141e706e864f304edbd9b50762d7e005bf9a9.tar.gz
sonarqube-644141e706e864f304edbd9b50762d7e005bf9a9.zip
SONAR-6762 - Create 'issues' analysis mode
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java1
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoaderGlobalProvider.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/CpdSensor.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobWrapper.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java25
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectWSLoaderProvider.java15
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/WSLoaderGlobalProviderTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesIssuesModeMediumTest.java (renamed from sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesPreviewMediumTest.java)8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/EmptyFileTest.java15
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IssueModeAndReportsMediumTest.java (renamed from sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java)6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/WSLoaderProjectProviderTest.java14
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/sensor/SensorOptimizerTest.java14
34 files changed, 103 insertions, 100 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java
index 33ec869e23e..03a82d2752e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java
@@ -61,3 +61,4 @@ public class GlobalMode {
}
}
}
+
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoaderGlobalProvider.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoaderGlobalProvider.java
index 2d9a76252a8..71826511f1d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoaderGlobalProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/WSLoaderGlobalProvider.java
@@ -20,7 +20,6 @@
package org.sonar.batch.bootstrap;
import org.picocontainer.injectors.ProviderAdapter;
-
import org.sonar.batch.bootstrap.WSLoader.LoadStrategy;
import java.util.Map;
@@ -33,14 +32,13 @@ public class WSLoaderGlobalProvider extends ProviderAdapter {
public WSLoader provide(BootstrapProperties props, GlobalMode mode, PersistentCache cache, ServerClient client) {
if (wsLoader == null) {
- wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode.isPreview()), cache, client);
+ wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode), cache, client);
wsLoader.setStrategy(DEFAULT_STRATEGY);
}
return wsLoader;
}
- private static boolean isCacheEnabled(Map<String, String> props, boolean isPreview) {
- String enableOffline = props.get("sonar.enableOffline");
- return isPreview && "true".equals(enableOffline);
+ private static boolean isCacheEnabled(Map<String, String> props, GlobalMode mode) {
+ return mode.isIssues();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdSensor.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdSensor.java
index d4ba5397783..ed41921c9eb 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdSensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdSensor.java
@@ -50,7 +50,7 @@ public class CpdSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
descriptor.name("CPD Sensor")
- .disabledInPreview();
+ .disabledInIssues();
}
@VisibleForTesting
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
index d9d6a444080..a1d37f682db 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
@@ -52,8 +52,8 @@ public class IndexFactory {
boolean crossProject = false;
if (settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT)) {
- if (mode.isPreview()) {
- logger.info("Cross-project analysis disabled. Not supported in preview mode.");
+ if (mode.isIssues()) {
+ logger.info("Cross-project analysis disabled. Not supported in issues mode.");
} else if (StringUtils.isNotBlank(settings.getString(CoreProperties.PROJECT_BRANCH_PROPERTY))) {
logger.info("Cross-project analysis disabled. Not supported on project branches.");
} else if (project == null) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
index 580eb12d2a2..a4f7c8c8b2e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
@@ -76,7 +76,7 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
issues.add(issue);
}
- if (!container.getComponentByType(AnalysisMode.class).isPreview()) {
+ if (!container.getComponentByType(AnalysisMode.class).isIssues()) {
ReportPublisher reportPublisher = container.getComponentByType(ReportPublisher.class);
reader = new BatchReportReader(reportPublisher.getReportDir());
Metadata readMetadata = getReportReader().readMetadata();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java
index 08152c55fbe..780c39cc3cb 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PhaseExecutor.java
@@ -99,7 +99,7 @@ public final class PhaseExecutor {
sensorsExecutor.execute(sensorContext);
if (module.isRoot()) {
- if (analysisMode.isPreview()) {
+ if (analysisMode.isIssues()) {
localIssueTracking();
issuesCallback();
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
index 624c1f1574e..94168b0f406 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
@@ -47,8 +47,8 @@ public class PostJobOptimizer {
LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
return false;
}
- if (descriptor.isDisabledInPreview() && analysisMode.isPreview()) {
- LOG.debug("'{}' skipped in preview mode", descriptor.name());
+ if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) {
+ LOG.debug("'{}' skipped in issues mode", descriptor.name());
return false;
}
return true;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobWrapper.java b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobWrapper.java
index 45182e69ee5..fe97c03b6e6 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobWrapper.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobWrapper.java
@@ -39,7 +39,7 @@ public class PostJobWrapper implements org.sonar.api.batch.PostJob, CheckProject
public PostJobWrapper(PostJob newPostJob, PostJobContext adaptor, PostJobOptimizer optimizer) {
this.wrappedPostJob = newPostJob;
this.optimizer = optimizer;
- descriptor = new DefaultPostJobDescriptor();
+ this.descriptor = new DefaultPostJobDescriptor();
newPostJob.describe(descriptor);
this.adaptor = adaptor;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
index 2435330b613..0772cbda31f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
@@ -103,8 +103,8 @@ public class ReportPublisher implements Startable {
}
public void execute() {
- // If this is a preview analysis then we should not upload reports
- if (!analysisMode.isPreview()) {
+ // If this is a issues mode analysis then we should not upload reports
+ if (!analysisMode.isIssues()) {
File report = prepareReport();
if (!analysisMode.isMediumTest()) {
sendOrDumpReport(report);
@@ -202,7 +202,7 @@ public class ReportPublisher implements Startable {
@VisibleForTesting
void logSuccess(Logger logger) {
- if (analysisMode.isPreview() || analysisMode.isMediumTest()) {
+ if (analysisMode.isIssues() || analysisMode.isMediumTest()) {
logger.info("ANALYSIS SUCCESSFUL");
} else {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
index fe54870a567..aa79cc382af 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/ProjectRepositoriesProvider.java
@@ -46,7 +46,7 @@ public class ProjectRepositoriesProvider extends ProviderAdapter {
profiler.stopInfo();
}
- if (analysisMode.isPreview() && projectReferentials.lastAnalysisDate() == null) {
+ if (analysisMode.isIssues() && projectReferentials.lastAnalysisDate() == null) {
LOG.warn("No analysis has been found on the server for this project. All issues will be marked as 'new'.");
}
}
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 ef602db802a..0f2d528a49c 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
@@ -48,8 +48,8 @@ public class QProfileSensor implements Sensor {
public boolean shouldExecuteOnProject(Project project) {
// Should be only executed on leaf modules
return project.getModules().isEmpty()
- // Useless in preview mode
- && !analysisMode.isPreview();
+ // Useless in issues mode
+ && !analysisMode.isIssues();
}
@Override
@@ -61,7 +61,7 @@ public class QProfileSensor implements Sensor {
used.add(profile);
}
}
- Measure detailsMeasure = new Measure(CoreMetrics.QUALITY_PROFILES, used.toJson());
+ Measure<?> detailsMeasure = new Measure<String>(CoreMetrics.QUALITY_PROFILES, used.toJson());
context.saveMeasure(detailsMeasure);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
index cf5a3c44fd9..a5e2e20d6f4 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleSettings.java
@@ -81,9 +81,9 @@ public class ModuleSettings extends Settings {
@Override
protected void doOnGetProperties(String key) {
- if (analysisMode.isPreview() && key.endsWith(".secured") && !key.contains(".license")) {
+ if (analysisMode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
throw MessageException.of("Access to the secured property '" + key
- + "' is not possible in preview mode. The SonarQube plugin which requires this property must be deactivated in preview mode.");
+ + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
}
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java
index 5ebd094360c..cab19aee1f0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java
@@ -39,7 +39,7 @@ public class ProjectAnalysisMode implements AnalysisMode {
private static final Logger LOG = LoggerFactory.getLogger(ProjectAnalysisMode.class);
private boolean preview;
- private boolean quick;
+ private boolean issues;
private boolean mediumTestMode;
public ProjectAnalysisMode(BootstrapProperties globalProps, AnalysisProperties props) {
@@ -48,12 +48,12 @@ public class ProjectAnalysisMode implements AnalysisMode {
@Override
public boolean isPreview() {
- return preview || quick;
+ return preview;
}
@Override
- public boolean isQuick() {
- return quick;
+ public boolean isIssues() {
+ return issues;
}
public boolean isMediumTest() {
@@ -62,11 +62,11 @@ public class ProjectAnalysisMode implements AnalysisMode {
private void init(Map<String, String> globalProps, Map<String, String> analysisProps) {
// make sure analysis is consistent with global properties
- boolean globalPreview = isPreview(globalProps);
- boolean analysisPreview = isPreview(analysisProps);
+ boolean globalPreview = isIssues(globalProps);
+ boolean analysisPreview = isIssues(analysisProps);
if (!globalPreview && analysisPreview) {
- throw new IllegalStateException("Inconsistent properties: global properties doesn't enable preview mode while analysis properties enables it");
+ throw new IllegalStateException("Inconsistent properties: global properties doesn't enable issues mode while analysis properties enables it");
}
load(globalProps, analysisProps);
@@ -80,14 +80,14 @@ public class ProjectAnalysisMode implements AnalysisMode {
String mode = getPropertyWithFallback(analysisProps, globalProps, CoreProperties.ANALYSIS_MODE);
validate(mode);
preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
- quick = CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
+ issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
}
mediumTestMode = "true".equals(getPropertyWithFallback(analysisProps, globalProps, BatchMediumTester.MEDIUM_TEST_ENABLED));
if (preview) {
LOG.info("Preview mode");
- } else if (quick) {
- LOG.info("Quick mode");
+ } else if (issues) {
+ LOG.info("Issues mode");
}
if (mediumTestMode) {
LOG.info("Medium test mode");
@@ -102,11 +102,10 @@ public class ProjectAnalysisMode implements AnalysisMode {
return props2.get(key);
}
- private static boolean isPreview(Map<String, String> props) {
+ private static boolean isIssues(Map<String, String> props) {
String mode = props.get(CoreProperties.ANALYSIS_MODE);
- return "true".equals(props.get(CoreProperties.DRY_RUN)) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) ||
- CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
+ return CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
}
private void validate(String mode) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
index 5066ccfc524..07e86e07b24 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java
@@ -67,9 +67,9 @@ public class ProjectSettings extends Settings {
@Override
protected void doOnGetProperties(String key) {
- if (mode.isPreview() && key.endsWith(".secured") && !key.contains(".license")) {
+ if (mode.isIssues() && key.endsWith(".secured") && !key.contains(".license")) {
throw MessageException.of("Access to the secured property '" + key
- + "' is not possible in preview mode. The SonarQube plugin which requires this property must be deactivated in preview mode.");
+ + "' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
}
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectWSLoaderProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectWSLoaderProvider.java
index e3caa1daaba..596c6df3069 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectWSLoaderProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectWSLoaderProvider.java
@@ -31,28 +31,29 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.batch.bootstrap.WSLoader.LoadStrategy;
public class ProjectWSLoaderProvider extends ProviderAdapter {
+ private static final String OPTIMIZE_STRING_PROP = "sonar.optimizeForSpeed";
private WSLoader wsLoader;
public WSLoader provide(AnalysisProperties props, AnalysisMode mode, PersistentCache cache, ServerClient client) {
if (wsLoader == null) {
// recreate cache directory if needed for this analysis
cache.reconfigure();
- wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode.isPreview()), cache, client);
- wsLoader.setStrategy(getStrategy(mode));
+ wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode), cache, client);
+ wsLoader.setStrategy(getStrategy(props.properties(), mode));
}
return wsLoader;
}
- private static LoadStrategy getStrategy(AnalysisMode mode) {
- if (mode.isQuick()) {
+ private static LoadStrategy getStrategy(Map<String, String> props, AnalysisMode mode) {
+ String optimizeForSpeed = props.get(OPTIMIZE_STRING_PROP);
+ if (mode.isIssues() && "true".equals(optimizeForSpeed)) {
return LoadStrategy.CACHE_FIRST;
}
return LoadStrategy.SERVER_FIRST;
}
- private static boolean isCacheEnabled(Map<String, String> props, boolean isPreview) {
- String enableOffline = props.get("sonar.enableOffline");
- return isPreview && "true".equals(enableOffline);
+ private static boolean isCacheEnabled(Map<String, String> props, AnalysisMode mode) {
+ return mode.isIssues();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
index 9aaf25528c6..f2b0c18d61a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
@@ -35,7 +35,7 @@ public class IssuesReports {
}
public void execute() {
- if (analysisMode.isPreview() || analysisMode.isMediumTest()) {
+ if (analysisMode.isIssues() || analysisMode.isMediumTest()) {
for (Reporter reporter : reporters) {
reporter.execute();
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
index a0b767e5c71..d9e44531827 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
@@ -78,7 +78,7 @@ public final class ScmConfiguration implements Startable {
@Override
public void start() {
- if (analysisMode.isPreview()) {
+ if (analysisMode.isIssues()) {
return;
}
if (isDisabled()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java
index a57fb5556c3..62144aa09d0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java
@@ -62,7 +62,7 @@ public final class ScmSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
descriptor.name("SCM Sensor")
- .disabledInPreview();
+ .disabledInIssues();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
index 3200b9f0f15..4ecec6fd5a2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
@@ -66,6 +66,10 @@ public class SensorOptimizer {
LOG.debug("'{}' skipped in preview mode", descriptor.name());
return false;
}
+ if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) {
+ LOG.debug("'{}' skipped in issues mode", descriptor.name());
+ return false;
+ }
return true;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
index 95d553a7ff5..59974f4a9e5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
@@ -45,7 +45,7 @@ public final class CodeColorizerSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
descriptor.name("Code Colorizer Sensor")
- .disabledInPreview();
+ .disabledInIssues();
}
@Override
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
index 1c01582f13a..bbdbcf78aa3 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
@@ -29,12 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat;
public class GlobalModeTest {
@Test
- public void testQuick() {
- GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_QUICK);
- assertThat(mode.isPreview()).isTrue();
- }
-
- @Test
public void testPreview() {
GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW);
assertThat(mode.isPreview()).isTrue();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/WSLoaderGlobalProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/WSLoaderGlobalProviderTest.java
index 8cc8b118018..81a5fdb563f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/WSLoaderGlobalProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/WSLoaderGlobalProviderTest.java
@@ -67,7 +67,7 @@ public class WSLoaderGlobalProviderTest {
public void testOffline() {
propMap = new HashMap<>();
propMap.put("sonar.enableOffline", "true");
- when(mode.isPreview()).thenReturn(true);
+ when(mode.isIssues()).thenReturn(true);
props = new BootstrapProperties(propMap);
WSLoader wsLoader = loaderProvider.provide(props, mode, cache, client);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
index af5a763c26d..c9bc8a41ed6 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
@@ -65,11 +65,11 @@ public class IndexFactoryTest {
}
@Test
- public void cross_project_should_be_disabled_on_preview() {
- when(analysisMode.isPreview()).thenReturn(true);
+ public void cross_project_should_be_disabled_on_issues_mode() {
+ when(analysisMode.isIssues()).thenReturn(true);
settings.setProperty(CoreProperties.CPD_CROSS_PROJECT, "true");
assertThat(factory.verifyCrossProject(project, logger)).isFalse();
- verify(logger).info("Cross-project analysis disabled. Not supported in preview mode.");
+ verify(logger).info("Cross-project analysis disabled. Not supported in issues mode.");
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesPreviewMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesIssuesModeMediumTest.java
index e1f96fa0e74..59ef4b792c4 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesPreviewMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesIssuesModeMediumTest.java
@@ -40,7 +40,7 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
-public class IssuesPreviewMediumTest {
+public class IssuesIssuesModeMediumTest {
@org.junit.Rule
public TemporaryFolder temp = new TemporaryFolder();
@@ -48,7 +48,7 @@ public class IssuesPreviewMediumTest {
.registerPlugin("xoo", new XooPlugin())
.addDefaultQProfile("xoo", "Sonar Way")
.addRules(new XooRulesDefinition())
- .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW))
+ .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES))
.activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", "OneIssuePerLine.internal", "xoo"))
.setLastBuildDate(new Date())
.build();
@@ -73,7 +73,7 @@ public class IssuesPreviewMediumTest {
TaskResult result1 = testerPreview
.newScanTask(new File(tmpDir, "sonar-project.properties"))
.setIssueListener(issueListener)
- .property(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW)
+ .property(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES)
.start();
assertThat(result1.trackedIssues()).hasSize(14);
@@ -83,7 +83,7 @@ public class IssuesPreviewMediumTest {
TaskResult result2 = testerPreview
.newScanTask(new File(tmpDir, "sonar-project.properties"))
.setIssueListener(issueListener)
- .property(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW)
+ .property(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES)
.start();
assertThat(result2.trackedIssues()).hasSize(28);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/EmptyFileTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/EmptyFileTest.java
index 37cb1fd994d..f6849c64756 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/EmptyFileTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/EmptyFileTest.java
@@ -19,8 +19,10 @@
*/
package org.sonar.batch.mediumtest.preview;
-import org.sonar.xoo.rule.XooRulesDefinition;
+import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.apache.commons.io.FileUtils;
+import org.sonar.xoo.rule.XooRulesDefinition;
import com.google.common.collect.ImmutableMap;
import org.junit.After;
import org.junit.Before;
@@ -48,7 +50,7 @@ public class EmptyFileTest {
public LogTester logTester = new LogTester();
public BatchMediumTester tester = BatchMediumTester.builder()
- .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW))
+ .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES))
.registerPlugin("xoo", new XooPlugin())
.addRules(new XooRulesDefinition())
.addDefaultQProfile("xoo", "Sonar Way")
@@ -68,7 +70,7 @@ public class EmptyFileTest {
@Test
public void testIssueTrackingWithIssueOnEmptyFile() throws Exception {
- File projectDir = new File(EmptyFileTest.class.getResource("/mediumtest/xoo/sample-with-empty-file").toURI());
+ File projectDir = copyProject("/mediumtest/xoo/sample-with-empty-file");
TaskResult result = tester
.newScanTask(new File(projectDir, "sonar-project.properties"))
@@ -78,4 +80,11 @@ public class EmptyFileTest {
assertThat(result.trackedIssues()).hasSize(11);
}
+ private File copyProject(String path) throws Exception {
+ File projectDir = temp.newFolder();
+ File originalProjectDir = new File(EmptyFileTest.class.getResource(path).toURI());
+ FileUtils.copyDirectory(originalProjectDir, projectDir, FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar")));
+ return projectDir;
+ }
+
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IssueModeAndReportsMediumTest.java
index fa324d08bf7..92743b4f125 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/PreviewAndReportsMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IssueModeAndReportsMediumTest.java
@@ -49,7 +49,7 @@ import org.sonar.xoo.XooPlugin;
import org.sonar.xoo.rule.XooRulesDefinition;
import static org.assertj.core.api.Assertions.assertThat;
-public class PreviewAndReportsMediumTest {
+public class IssueModeAndReportsMediumTest {
@org.junit.Rule
public TemporaryFolder temp = new TemporaryFolder();
@@ -68,7 +68,7 @@ public class PreviewAndReportsMediumTest {
}
public BatchMediumTester tester = BatchMediumTester.builder()
- .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW))
+ .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES))
.registerPlugin("xoo", new XooPlugin())
.addDefaultQProfile("xoo", "Sonar Way")
.addRules(new XooRulesDefinition())
@@ -138,7 +138,7 @@ public class PreviewAndReportsMediumTest {
private File copyProject(String path) throws Exception {
File projectDir = temp.newFolder();
- File originalProjectDir = new File(PreviewAndReportsMediumTest.class.getResource(path).toURI());
+ File originalProjectDir = new File(IssueModeAndReportsMediumTest.class.getResource(path).toURI());
FileUtils.copyDirectory(originalProjectDir, projectDir, FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar")));
return projectDir;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
index 1a16a8868b9..3fe56c92312 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
@@ -69,12 +69,12 @@ public class PostJobOptimizerTest {
}
@Test
- public void should_disabled_in_preview() {
+ public void should_disabled_in_issues_mode() {
DefaultPostJobDescriptor descriptor = new DefaultPostJobDescriptor()
- .disabledInPreview();
+ .disabledInIssues();
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
- when(analysisMode.isPreview()).thenReturn(true);
+ when(analysisMode.isIssues()).thenReturn(true);
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java
index df097d68457..10141350e88 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java
@@ -62,9 +62,9 @@ public class ReportPublisherTest {
}
@Test
- public void should_log_successful_preview_analysis() {
+ public void should_log_successful_issues_analysis() {
Settings settings = new Settings();
- when(mode.isPreview()).thenReturn(true);
+ when(mode.isIssues()).thenReturn(true);
ReportPublisher job = new ReportPublisher(settings, mock(ServerClient.class), mock(Server.class), reactor, mode, mock(TempFolder.class), new ReportPublisherStep[0]);
Logger logger = mock(Logger.class);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java
index 81a9afb5938..3c99da255b8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileSensorTest.java
@@ -68,9 +68,9 @@ public class QProfileSensorTest {
}
@Test
- public void no_execution_in_preview() {
+ public void no_execution_in_issues_mode() {
AnalysisMode analysisMode = mock(AnalysisMode.class);
- when(analysisMode.isPreview()).thenReturn(true);
+ when(analysisMode.isIssues()).thenReturn(true);
QProfileSensor sensor = new QProfileSensor(moduleQProfiles, fs, analysisMode);
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
index 4edec303f85..032bc858b32 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ModuleSettingsTest.java
@@ -102,7 +102,7 @@ public class ModuleSettingsTest {
}
@Test
- public void should_fail_when_accessing_secured_properties_in_preview() {
+ public void should_fail_when_accessing_secured_properties_in_issues() {
GlobalSettings batchSettings = mock(GlobalSettings.class);
when(batchSettings.getDefinitions()).thenReturn(new PropertyDefinitions());
when(batchSettings.getProperties()).thenReturn(ImmutableMap.of(
@@ -110,7 +110,7 @@ public class ModuleSettingsTest {
));
projectRef.addSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
- when(mode.isPreview()).thenReturn(true);
+ when(mode.isIssues()).thenReturn(true);
ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
@@ -120,7 +120,7 @@ public class ModuleSettingsTest {
thrown.expect(MessageException.class);
thrown
- .expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in preview mode. The SonarQube plugin which requires this property must be deactivated in preview mode.");
+ .expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
moduleSettings.getString("sonar.foo.secured");
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
index 18e24b9d1dd..a5bfe6ce70d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
@@ -42,7 +42,7 @@ public class ProjectAnalysisModeTest {
@Test(expected = IllegalStateException.class)
public void fail_if_inconsistent() {
- createMode(null, CoreProperties.ANALYSIS_MODE_PREVIEW);
+ createMode(null, CoreProperties.ANALYSIS_MODE_ISSUES);
}
@Test
@@ -65,11 +65,10 @@ public class ProjectAnalysisModeTest {
}
@Test
- public void support_quick_mode() {
- ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_QUICK);
+ public void support_issues_mode() {
+ ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_ISSUES);
- assertThat(mode.isPreview()).isTrue();
- assertThat(mode.isQuick()).isTrue();
+ assertThat(mode.isIssues()).isTrue();
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
index 5b4e60f4bc0..1d923e27a26 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
@@ -109,14 +109,14 @@ public class ProjectSettingsTest {
public void should_fail_when_accessing_secured_properties_in_dryrun() {
projectRef.addSettings("struts", ImmutableMap.of("sonar.foo.secured", "bar", "sonar.foo.license.secured", "bar2"));
- when(mode.isPreview()).thenReturn(true);
+ when(mode.isIssues()).thenReturn(true);
ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, new PropertyDefinitions(), projectRef, mode);
assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
thrown.expect(MessageException.class);
thrown
- .expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in preview mode. The SonarQube plugin which requires this property must be deactivated in preview mode.");
+ .expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
batchSettings.getString("sonar.foo.secured");
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/WSLoaderProjectProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/WSLoaderProjectProviderTest.java
index ae72b15cd13..c0366c40af6 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/WSLoaderProjectProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/WSLoaderProjectProviderTest.java
@@ -33,8 +33,6 @@ import org.sonar.home.cache.PersistentCache;
import java.util.HashMap;
import java.util.Map;
-import static org.mockito.Mockito.when;
-
import static org.assertj.core.api.Assertions.assertThat;
public class WSLoaderProjectProviderTest {
@@ -66,16 +64,4 @@ public class WSLoaderProjectProviderTest {
assertThat(loader.getStrategy()).isEqualTo(LoadStrategy.SERVER_FIRST);
assertThat(loader.isCacheEnabled()).isEqualTo(false);
}
-
- @Test
- public void testSingleMode() {
- when(mode.isQuick()).thenReturn(true);
- when(mode.isPreview()).thenReturn(true);
- propMap.put("sonar.enableOffline", "true");
- props = new AnalysisProperties(propMap, null);
-
- WSLoader loader = loaderProvider.provide(props, mode, cache, client);
- assertThat(loader.getStrategy()).isEqualTo(LoadStrategy.CACHE_FIRST);
- assertThat(loader.isCacheEnabled()).isEqualTo(true);
- }
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/sensor/SensorOptimizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/sensor/SensorOptimizerTest.java
index 968544e84fa..15f334dadee 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/sensor/SensorOptimizerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/sensor/SensorOptimizerTest.java
@@ -139,7 +139,7 @@ public class SensorOptimizerTest {
}
@Test
- public void should_disabled_in_preview() {
+ public void should_disabled_in_preview_mode() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor()
.disabledInPreview();
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
@@ -148,4 +148,16 @@ public class SensorOptimizerTest {
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
}
+
+ @Test
+ public void should_disabled_in_issues_mode() {
+ DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor()
+ .disabledInIssues();
+ assertThat(optimizer.shouldExecute(descriptor)).isTrue();
+
+ when(analysisMode.isIssues()).thenReturn(true);
+
+ assertThat(optimizer.shouldExecute(descriptor)).isFalse();
+ }
+
}