Skip to content

Commit

Permalink
SCANMAVEN-220 Revert "Make sonar.maven.scanAll true by default" (#226)
Browse files Browse the repository at this point in the history
This reverts commit 990c59d. 
The `sonar.maven.scanAll` true by default will be delivered in a future version.
  • Loading branch information
ADarko22 authored May 28, 2024
1 parent f4ad3da commit 1b68124
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions its/src/test/java/com/sonar/maven/it/suite/MavenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ void shouldSupportJeeProjects() {
ORCHESTRATOR.executeBuild(build);

// src/main/webapp is analyzed by web and xml plugin
// scanning all files, so 2 more files (ejb-module/src/main/resources/META-INF/ejb-jar.xml and web-module/src/main/webapp/index.jsp)
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.jee:parent", "files")).isEqualTo(10);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.jee:parent", "files")).isEqualTo(9);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/it/java-multi-module/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def sources = 'sonar.sources'
def module1Sources = "org.codehaus.sonar:sample-project-module1.$sources"

assert properties."$module1Sources" == properties."$projectBaseDir" + "/module1/pom.xml"
assert properties."$sources" == properties."$projectBaseDir" + "/pom.xml" + "," + properties."$projectBaseDir" + "/verify.groovy"
assert properties."$sources" == properties."$projectBaseDir" + "/pom.xml"
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ Map<String, String> collectProperties()
}

private static boolean shouldCollectAllSources(Properties userProperties) {
String sonarScanAll = userProperties.getProperty(MavenScannerProperties.PROJECT_SCAN_ALL_SOURCES, Boolean.TRUE.toString());
return Boolean.TRUE.equals(Boolean.parseBoolean(sonarScanAll));
return Boolean.TRUE.equals(Boolean.parseBoolean(userProperties.getProperty(MavenScannerProperties.PROJECT_SCAN_ALL_SOURCES)));
}

private static String notCollectingAdditionalSourcesBecauseOf(String overriddenProperty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.*;
import org.sonarsource.scanner.api.EmbeddedScanner;
Expand Down Expand Up @@ -155,17 +152,16 @@ void testNullServerVersion() {
}

@Test
void scanAll_property_is_applied_by_default() throws MojoExecutionException {
void scanAll_property_is_not_applied_by_default() throws MojoExecutionException {
// When sonar.scanner.scanAll is not set
verifyCollectedSources(sourceDirs -> {
assertThat(sourceDirs).hasSize(3);
assertThat(sourceDirs).hasSize(2);
assertThat(sourceDirs[0]).endsWith(Paths.get("src", "main", "java").toString());
assertThat(sourceDirs[1]).endsWith(Paths.get("pom.xml").toString());
assertThat(sourceDirs[2]).endsWith(Paths.get("src", "main", "resources", "index.js").toString());
});

verify(log, times(1)).info("Parameter sonar.maven.scanAll is enabled. The scanner will attempt to collect additional sources.");
verify(scannerBootstrapper, times(1)).collectAllSources(any(), eq(false));
verify(log, never()).info("Parameter sonar.maven.scanAll is enabled. The scanner will attempt to collect additional sources.");
verify(scannerBootstrapper, never()).collectAllSources(any(), anyBoolean());
}

@Test
Expand Down

0 comments on commit 1b68124

Please sign in to comment.