Browse Source

SONAR-6761 Drop incremental mode

tags/5.2-RC1
Duarte Meneses 8 years ago
parent
commit
92ab7df5f6

+ 1
- 2
sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java View File

@@ -40,8 +40,7 @@ public class GlobalMode {
preview = "true".equals(props.property(CoreProperties.DRY_RUN));
} else {
String mode = props.property(CoreProperties.ANALYSIS_MODE);
preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) || CoreProperties.ANALYSIS_MODE_INCREMENTAL.equals(mode) ||
CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) || CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
}

if (preview) {

+ 1
- 10
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java View File

@@ -31,7 +31,6 @@ import java.util.Set;
import javax.annotation.CheckForNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.rule.ActiveRule;
@@ -69,7 +68,6 @@ public class LocalIssueTracking {
private final ActiveRules activeRules;
private final BatchComponentCache componentCache;
private final ServerIssueRepository serverIssueRepository;
private final AnalysisMode analysisMode;
private final ReportPublisher reportPublisher;
private final Date analysisDate;

@@ -78,7 +76,7 @@ public class LocalIssueTracking {
public LocalIssueTracking(BatchComponentCache resourceCache, IssueCache issueCache, IssueTracking tracking,
ServerLineHashesLoader lastLineHashes, IssueWorkflow workflow, IssueUpdater updater,
ActiveRules activeRules, ServerIssueRepository serverIssueRepository,
ProjectRepositories projectRepositories, AnalysisMode analysisMode, ReportPublisher reportPublisher) {
ProjectRepositories projectRepositories, ReportPublisher reportPublisher) {
this.componentCache = resourceCache;
this.issueCache = issueCache;
this.tracking = tracking;
@@ -86,7 +84,6 @@ public class LocalIssueTracking {
this.workflow = workflow;
this.updater = updater;
this.serverIssueRepository = serverIssueRepository;
this.analysisMode = analysisMode;
this.reportPublisher = reportPublisher;
this.analysisDate = ((Project) resourceCache.getRoot().resource()).getAnalysisDate();
this.changeContext = IssueChangeContext.createScan(analysisDate);
@@ -107,12 +104,6 @@ public class LocalIssueTracking {
}

public void trackIssues(BatchReportReader reader, BatchComponent component) {

if (analysisMode.isIncremental() && !component.isFile()) {
// No need to report issues on project or directories in preview mode since it is likely to be wrong anyway
return;
}

// raw issues = all the issues created by rule engines during this module scan and not excluded by filters
Set<BatchReport.Issue> rawIssues = Sets.newIdentityHashSet();
try (CloseableIterator<BatchReport.Issue> it = reader.readComponentIssues(component.batchId())) {

+ 2
- 47
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java View File

@@ -21,17 +21,10 @@ package org.sonar.batch.issue.tracking;

import com.google.common.base.Function;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import javax.annotation.Nullable;

import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFile.Status;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.utils.log.Profiler;
@@ -42,7 +35,6 @@ import org.sonar.batch.index.Caches;
import org.sonar.batch.protocol.input.BatchInput.ServerIssue;
import org.sonar.batch.repository.ServerIssuesLoader;
import org.sonar.batch.scan.ImmutableProjectReactor;
import org.sonar.batch.scan.filesystem.InputPathCache;
import org.sonar.core.component.ComponentKeys;

@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
@@ -56,21 +48,15 @@ public class ServerIssueRepository {
private final ServerIssuesLoader previousIssuesLoader;
private final ImmutableProjectReactor reactor;
private final BatchComponentCache resourceCache;
private final AnalysisMode analysisMode;

public ServerIssueRepository(Caches caches, ServerIssuesLoader previousIssuesLoader, ImmutableProjectReactor reactor, BatchComponentCache resourceCache,
AnalysisMode analysisMode) {
public ServerIssueRepository(Caches caches, ServerIssuesLoader previousIssuesLoader, ImmutableProjectReactor reactor, BatchComponentCache resourceCache) {
this.caches = caches;
this.previousIssuesLoader = previousIssuesLoader;
this.reactor = reactor;
this.resourceCache = resourceCache;
this.analysisMode = analysisMode;
}

public void load() {
if (analysisMode.isIncremental()) {
return;
}
Profiler profiler = Profiler.create(LOG).startInfo("Load server issues");
this.issuesCache = caches.createCache("previousIssues");
caches.registerValueCoder(ServerIssue.class, new ServerIssueValueCoder());
@@ -79,22 +65,7 @@ public class ServerIssueRepository {
}

public Iterable<ServerIssue> byComponent(BatchComponent component) {
if (analysisMode.isIncremental()) {
if (!component.isFile()) {
throw new UnsupportedOperationException("Incremental mode should only get issues on files");
}
InputFile inputFile = (InputFile) component.inputComponent();
if (inputFile.status() == Status.ADDED) {
return Collections.emptyList();
}
Profiler profiler = Profiler.create(LOG).startInfo("Load server issues for " + component.resource().getPath());
ServerIssueConsumer consumer = new ServerIssueConsumer();
boolean fromCache = previousIssuesLoader.load(component.key(), consumer, true);
stopDebug(profiler, "Load server issues for " + component.resource().getPath(), fromCache);
return consumer.issueList;
} else {
return issuesCache.values(component.batchId());
}
return issuesCache.values(component.batchId());
}

private static void stopDebug(Profiler profiler, String msg, boolean fromCache) {
@@ -124,23 +95,7 @@ public class ServerIssueRepository {
}
}

private static class ServerIssueConsumer implements Function<ServerIssue, Void> {
List<ServerIssue> issueList = new LinkedList<>();

@Override
public Void apply(@Nullable ServerIssue issue) {
if (issue == null) {
return null;
}
issueList.add(issue);
return null;
}
}

public Iterable<ServerIssue> issuesOnMissingComponents() {
if (analysisMode.isIncremental()) {
throw new UnsupportedOperationException("Only issues of analyzed components are loaded in incremental mode");
}
return issuesCache.values(0);
}
}

+ 3
- 13
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java View File

@@ -39,7 +39,6 @@ public class ProjectAnalysisMode implements AnalysisMode {
private static final Logger LOG = LoggerFactory.getLogger(ProjectAnalysisMode.class);

private boolean preview;
private boolean incremental;
private boolean quick;
private boolean mediumTestMode;

@@ -49,7 +48,7 @@ public class ProjectAnalysisMode implements AnalysisMode {

@Override
public boolean isPreview() {
return preview || incremental || quick;
return preview || quick;
}

@Override
@@ -57,11 +56,6 @@ public class ProjectAnalysisMode implements AnalysisMode {
return quick;
}

@Override
public boolean isIncremental() {
return incremental;
}

public boolean isMediumTest() {
return mediumTestMode;
}
@@ -82,18 +76,14 @@ public class ProjectAnalysisMode implements AnalysisMode {
if (getPropertyWithFallback(analysisProps, globalProps, CoreProperties.DRY_RUN) != null) {
LOG.warn(MessageFormat.format("Property {0} is deprecated. Please use {1} instead.", CoreProperties.DRY_RUN, CoreProperties.ANALYSIS_MODE));
preview = "true".equals(getPropertyWithFallback(analysisProps, globalProps, CoreProperties.DRY_RUN));
incremental = false;
} else {
String mode = getPropertyWithFallback(analysisProps, globalProps, CoreProperties.ANALYSIS_MODE);
preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
incremental = CoreProperties.ANALYSIS_MODE_INCREMENTAL.equals(mode);
quick = CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
}
mediumTestMode = "true".equals(getPropertyWithFallback(analysisProps, globalProps, BatchMediumTester.MEDIUM_TEST_ENABLED));

if (incremental) {
LOG.info("Incremental mode");
} else if (preview) {
if (preview) {
LOG.info("Preview mode");
} else if (quick) {
LOG.info("Quick mode");
@@ -115,6 +105,6 @@ public class ProjectAnalysisMode implements AnalysisMode {
String mode = props.get(CoreProperties.ANALYSIS_MODE);

return "true".equals(props.get(CoreProperties.DRY_RUN)) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) ||
CoreProperties.ANALYSIS_MODE_INCREMENTAL.equals(mode) || CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
}
}

+ 2
- 8
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java View File

@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;

import org.sonar.batch.scan.ProjectAnalysisMode;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
@@ -44,18 +42,16 @@ class InputFileBuilder {
private final LanguageDetection langDetection;
private final StatusDetection statusDetection;
private final DefaultModuleFileSystem fs;
private final ProjectAnalysisMode analysisMode;
private final Settings settings;
private final FileMetadata fileMetadata;

InputFileBuilder(String moduleKey, PathResolver pathResolver, LanguageDetection langDetection,
StatusDetection statusDetection, DefaultModuleFileSystem fs, ProjectAnalysisMode analysisMode, Settings settings, FileMetadata fileMetadata) {
StatusDetection statusDetection, DefaultModuleFileSystem fs, Settings settings, FileMetadata fileMetadata) {
this.moduleKey = moduleKey;
this.pathResolver = pathResolver;
this.langDetection = langDetection;
this.statusDetection = statusDetection;
this.fs = fs;
this.analysisMode = analysisMode;
this.settings = settings;
this.fileMetadata = fileMetadata;
}
@@ -108,9 +104,7 @@ class InputFileBuilder {
inputFile.initMetadata(fileMetadata.readMetadata(inputFile.file(), fs.encoding()));

inputFile.setStatus(statusDetection.status(inputFile.moduleKey(), inputFile.relativePath(), inputFile.hash()));
if (analysisMode.isIncremental() && inputFile.status() == InputFile.Status.SAME) {
return null;
}

return inputFile;
}


+ 2
- 6
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java View File

@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;

import org.sonar.batch.scan.ProjectAnalysisMode;

import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.FileMetadata;
@@ -34,22 +32,20 @@ public class InputFileBuilderFactory {
private final PathResolver pathResolver;
private final LanguageDetectionFactory langDetectionFactory;
private final StatusDetectionFactory statusDetectionFactory;
private final ProjectAnalysisMode analysisMode;
private final Settings settings;
private final FileMetadata fileMetadata;

public InputFileBuilderFactory(ProjectDefinition def, PathResolver pathResolver, LanguageDetectionFactory langDetectionFactory,
StatusDetectionFactory statusDetectionFactory, ProjectAnalysisMode analysisMode, Settings settings, FileMetadata fileMetadata) {
StatusDetectionFactory statusDetectionFactory, Settings settings, FileMetadata fileMetadata) {
this.fileMetadata = fileMetadata;
this.moduleKey = def.getKeyWithBranch();
this.pathResolver = pathResolver;
this.langDetectionFactory = langDetectionFactory;
this.statusDetectionFactory = statusDetectionFactory;
this.analysisMode = analysisMode;
this.settings = settings;
}

InputFileBuilder create(DefaultModuleFileSystem fs) {
return new InputFileBuilder(moduleKey, pathResolver, langDetectionFactory.create(), statusDetectionFactory.create(), fs, analysisMode, settings, fileMetadata);
return new InputFileBuilder(moduleKey, pathResolver, langDetectionFactory.create(), statusDetectionFactory.create(), fs, settings, fileMetadata);
}
}

+ 0
- 6
sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java View File

@@ -40,12 +40,6 @@ public class GlobalModeTest {
assertThat(mode.isPreview()).isTrue();
}

@Test
public void testIncremental() {
GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_INCREMENTAL);
assertThat(mode.isPreview()).isTrue();
}

@Test
public void testOtherProperty() {
GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ANALYSIS);

+ 0
- 155
sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IncrementalModeMediumTest.java View File

@@ -1,155 +0,0 @@
/*
* SonarQube, open source software quality management tool.
* Copyright (C) 2008-2014 SonarSource
* mailto:contact AT sonarsource DOT com
*
* SonarQube is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* SonarQube is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.batch.mediumtest.preview;

import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
import org.sonar.api.rule.RuleKey;
import org.sonar.batch.mediumtest.BatchMediumTester;
import org.sonar.batch.mediumtest.TaskResult;
import org.sonar.batch.protocol.Constants.Severity;
import org.sonar.batch.protocol.input.ActiveRule;
import org.sonar.batch.protocol.input.FileData;
import org.sonar.xoo.XooPlugin;
import org.sonar.xoo.rule.XooRulesDefinition;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;

public class IncrementalModeMediumTest {

private static final String SAMPLE_CONTENT = "Sample content\nwith\n4\nlines";

@org.junit.Rule
public TemporaryFolder temp = new TemporaryFolder();

private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

private static Long date(String date) {
try {
return sdf.parse(date).getTime();
} catch (ParseException e) {
throw new IllegalStateException(e);
}
}

public BatchMediumTester tester = BatchMediumTester
.builder()
.bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_INCREMENTAL))
.registerPlugin("xoo", new XooPlugin())
.addRules(new XooRulesDefinition())
.addDefaultQProfile("xoo", "Sonar Way")
.activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo"))
.activateRule(new ActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null))
.setPreviousAnalysisDate(new Date())
.addFileData("sample", "src/sample.xoo", new FileData(DigestUtils.md5Hex(SAMPLE_CONTENT), false))
.mockLineHashes("sample:src/sample.xoo",
new String[] {DigestUtils.md5Hex("Samplecontent"), DigestUtils.md5Hex("oldcode"), DigestUtils.md5Hex("4"), DigestUtils.md5Hex("lines")})
// Remote open issue => will be tracked and not new
.mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("xyz")
.setModuleKey("sample")
.setPath("src/sample.xoo")
.setRuleRepository("xoo")
.setRuleKey("OneIssuePerLine")
.setLine(1)
.setSeverity(Severity.MAJOR)
.setCreationDate(date("14/03/2004"))
.setChecksum(DigestUtils.md5Hex("Samplecontent"))
.setStatus("OPEN")
.build())
// Remote open issue that no more exists => will be closed
.mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("resolved")
.setModuleKey("sample")
.setPath("src/sample.xoo")
.setRuleRepository("xoo")
.setRuleKey("OneIssuePerFile")
.setMsg("An issue that is no more detected")
.setLine(2)
.setSeverity(Severity.MAJOR)
.setCreationDate(date("14/03/2004"))
.setChecksum(DigestUtils.md5Hex("oldcode"))
.setStatus("OPEN")
.build())
// Manual issue
.mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("manual")
.setModuleKey("sample")
.setPath("src/sample.xoo")
.setRuleRepository("manual")
.setRuleKey("MyManualIssue")
.setLine(4)
.setSeverity(Severity.MAJOR)
.setCreationDate(date("14/03/2004"))
.setChecksum(DigestUtils.md5Hex("lines"))
.setStatus("OPEN")
.build())
.build();

@Before
public void prepare() {
tester.start();
}

@After
public void stop() {
tester.stop();
}

@Test
public void testIssueTrackingIncrementalMode() throws Exception {
File baseDir = temp.newFolder();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();

File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, SAMPLE_CONTENT + "\nmodification");

TaskResult result = tester.newTask()
.properties(ImmutableMap.<String, String>builder()
.put("sonar.task", "scan")
.put("sonar.projectBaseDir", baseDir.getAbsolutePath())
.put("sonar.projectKey", "sample")
.put("sonar.projectName", "Foo Project")
.put("sonar.projectVersion", "1.0-SNAPSHOT")
.put("sonar.projectDescription", "Description of Foo Project")
.put("sonar.sources", "src")
.build())
.start();

assertThat(result.trackedIssues()).extracting("ruleKey", "line", "message", "status", "resolution", "new").containsOnly(
tuple(RuleKey.of("xoo", "OneIssuePerLine"), 1, "This issue is generated on each line", "OPEN", null, false),
tuple(RuleKey.of("xoo", "OneIssuePerLine"), 2, "This issue is generated on each line", "OPEN", null, true),
tuple(RuleKey.of("xoo", "OneIssuePerLine"), 3, "This issue is generated on each line", "OPEN", null, true),
tuple(RuleKey.of("xoo", "OneIssuePerLine"), 4, "This issue is generated on each line", "OPEN", null, true),
tuple(RuleKey.of("xoo", "OneIssuePerLine"), 5, "This issue is generated on each line", "OPEN", null, true),
tuple(RuleKey.of("manual", "MyManualIssue"), 4, null, "OPEN", null, false),
tuple(RuleKey.of("xoo", "OneIssuePerFile"), null, "An issue that is no more detected", "CLOSED", "REMOVED", false));
}

}

+ 0
- 14
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java View File

@@ -39,12 +39,10 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(null);

assertThat(mode.isPreview()).isFalse();
assertThat(mode.isIncremental()).isFalse();

mode = createMode(CoreProperties.ANALYSIS_MODE, "pouet");

assertThat(mode.isPreview()).isFalse();
assertThat(mode.isIncremental()).isFalse();
}

@Test(expected = IllegalStateException.class)
@@ -57,7 +55,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_ANALYSIS);

assertThat(mode.isPreview()).isFalse();
assertThat(mode.isIncremental()).isFalse();
}

@Test
@@ -65,7 +62,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_PREVIEW);

assertThat(mode.isPreview()).isTrue();
assertThat(mode.isIncremental()).isFalse();
}

@Test
@@ -73,18 +69,9 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_QUICK);

assertThat(mode.isPreview()).isTrue();
assertThat(mode.isIncremental()).isFalse();
assertThat(mode.isQuick()).isTrue();
}

@Test
public void support_incremental_mode() {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_INCREMENTAL);

assertThat(mode.isPreview()).isTrue();
assertThat(mode.isIncremental()).isTrue();
}

@Test
public void support_deprecated_dryrun_property() {
Map<String, String> bootstrapMap = new HashMap<>();
@@ -96,7 +83,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = new ProjectAnalysisMode(new BootstrapProperties(bootstrapMap), new AnalysisProperties(analysisMap));

assertThat(mode.isPreview()).isTrue();
assertThat(mode.isIncremental()).isFalse();
}

private static ProjectAnalysisMode createMode(@Nullable String mode) {

+ 1
- 4
sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java View File

@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;

import org.sonar.batch.scan.ProjectAnalysisMode;

import org.junit.Test;
import org.mockito.Mockito;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -37,10 +35,9 @@ public class InputFileBuilderFactoryTest {
LanguageDetectionFactory langDetectionFactory = mock(LanguageDetectionFactory.class, Mockito.RETURNS_MOCKS);
StatusDetectionFactory statusDetectionFactory = mock(StatusDetectionFactory.class, Mockito.RETURNS_MOCKS);
DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
ProjectAnalysisMode analysisMode = mock(ProjectAnalysisMode.class);

InputFileBuilderFactory factory = new InputFileBuilderFactory(ProjectDefinition.create().setKey("struts"), pathResolver, langDetectionFactory,
statusDetectionFactory, analysisMode, new Settings(), new FileMetadata());
statusDetectionFactory, new Settings(), new FileMetadata());
InputFileBuilder builder = factory.create(fs);

assertThat(builder.langDetection()).isNotNull();

+ 3
- 6
sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java View File

@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;

import org.sonar.batch.scan.ProjectAnalysisMode;

import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
@@ -48,7 +46,6 @@ public class InputFileBuilderTest {
LanguageDetection langDetection = mock(LanguageDetection.class);
StatusDetection statusDetection = mock(StatusDetection.class);
DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
ProjectAnalysisMode analysisMode = mock(ProjectAnalysisMode.class);

@Test
public void complete_input_file() throws Exception {
@@ -68,7 +65,7 @@ public class InputFileBuilderTest {
.thenReturn(InputFile.Status.ADDED);

InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);
builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);

@@ -91,7 +88,7 @@ public class InputFileBuilderTest {
when(fs.baseDir()).thenReturn(basedir);

InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);

assertThat(inputFile).isNull();
@@ -111,7 +108,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn(null);

InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);


+ 2
- 2
sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java View File

@@ -184,11 +184,11 @@ public class DefaultHttpDownloader extends HttpDownloader {
}

private void initUserAgent(@Nullable String sonarVersion) {
userAgent = (sonarVersion == null ? "SonarQube" : String.format("SonarQube %s", sonarVersion));
userAgent = sonarVersion == null ? "SonarQube" : String.format("SonarQube %s", sonarVersion);
System.setProperty("http.agent", userAgent);
}

private String getProxySynthesis(URI uri) {
private static String getProxySynthesis(URI uri) {
return getProxySynthesis(uri, ProxySelector.getDefault());
}


+ 3
- 1
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java View File

@@ -446,7 +446,7 @@ public interface CoreProperties {
* @since 4.0
*/
String ANALYSIS_MODE_PREVIEW = "preview";
/**
* @since 5.2
*/
@@ -454,7 +454,9 @@ public interface CoreProperties {

/**
* @since 4.0
* @deprecated since 5.2
*/
@Deprecated
String ANALYSIS_MODE_INCREMENTAL = "incremental";

/**

+ 0
- 2
sonar-plugin-api/src/main/java/org/sonar/api/batch/AnalysisMode.java View File

@@ -28,8 +28,6 @@ public interface AnalysisMode {

boolean isPreview();

boolean isIncremental();
boolean isQuick();

}

+ 0
- 10
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java View File

@@ -216,19 +216,9 @@ public class SensorContextTester implements SensorContext {
}

public static class MockAnalysisMode implements AnalysisMode {
private boolean isIncremental = false;
private boolean isPreview = false;
private boolean isSingle = false;

@Override
public boolean isIncremental() {
return isIncremental;
}

public void setIncremental(boolean value) {
this.isIncremental = value;
}

@Override
public boolean isPreview() {
return isPreview;

+ 0
- 3
sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java View File

@@ -77,10 +77,7 @@ public class SensorContextTesterTest {

@Test
public void testAnalysisMode() {
assertThat(tester.analysisMode().isIncremental()).isFalse();
assertThat(tester.analysisMode().isPreview()).isFalse();
tester.analysisMode().setIncremental(true);
assertThat(tester.analysisMode().isIncremental()).isTrue();
tester.analysisMode().setPreview(true);
assertThat(tester.analysisMode().isPreview()).isTrue();
}

Loading…
Cancel
Save