aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorBenoƮt Gianinetti <benoit.gianinetti@sonarsource.com>2019-03-14 15:07:47 +0100
committerSonarTech <sonartech@sonarsource.com>2019-03-19 20:21:28 +0100
commit0bc8757a169ea48a058655d1c9fff017482b6550 (patch)
tree206e70f4a6033155c140516492affed3838d7116 /sonar-scanner-engine
parente9417f72b362c8a2b754121b5da40cd3c15e604e (diff)
downloadsonarqube-0bc8757a169ea48a058655d1c9fff017482b6550.tar.gz
sonarqube-0bc8757a169ea48a058655d1c9fff017482b6550.zip
SONAR-11449 Drop deprecated property sonar.language
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java33
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java7
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java41
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties2
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties2
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties1
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties1
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties1
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties1
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties1
-rw-r--r--sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties1
12 files changed, 9 insertions, 87 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
index bb0a550f452..982d413a71f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
@@ -118,11 +118,8 @@ public class FileIndexer {
exclusionCounter.increaseByPatternsCount();
return;
}
+
String language = langDetection.language(realAbsoluteFile, projectRelativePath);
- if (language == null && langDetection.getForcedLanguage() != null) {
- LOG.warn("File '{}' is ignored because it doesn't belong to the forced language '{}'", realAbsoluteFile.toAbsolutePath(), langDetection.getForcedLanguage());
- return;
- }
if (ignoreCommand != null && ignoreCommand.isIgnored(realAbsoluteFile)) {
LOG.debug("File '{}' is excluded by the scm ignore settings.", realAbsoluteFile);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
index 1b74abd4aa9..57fbb86e23d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
@@ -32,7 +32,6 @@ import javax.annotation.concurrent.ThreadSafe;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.internal.PathPattern;
import org.sonar.api.config.Configuration;
import org.sonar.api.utils.MessageException;
@@ -52,7 +51,6 @@ public class LanguageDetection {
*/
private final Map<String, PathPattern[]> patternsByLanguage;
private final List<String> languagesToConsider;
- private final String forcedLanguage;
public LanguageDetection(Configuration settings, LanguagesRepository languages) {
Map<String, PathPattern[]> patternsByLanguageBuilder = new LinkedHashMap<>();
@@ -75,29 +73,10 @@ public class LanguageDetection {
}
}
- forcedLanguage = StringUtils.defaultIfBlank(settings.get(CoreProperties.PROJECT_LANGUAGE_PROPERTY).orElse(null), null);
- // First try with lang patterns
- if (forcedLanguage != null) {
- if (!patternsByLanguageBuilder.containsKey(forcedLanguage)) {
- throw MessageException.of("You must install a plugin that supports the language '" + forcedLanguage + "'");
- }
- LOG.info("Language is forced to {}", forcedLanguage);
- languagesToConsider = Collections.singletonList(forcedLanguage);
- } else {
- languagesToConsider = Collections.unmodifiableList(new ArrayList<>(patternsByLanguageBuilder.keySet()));
- }
-
+ languagesToConsider = Collections.unmodifiableList(new ArrayList<>(patternsByLanguageBuilder.keySet()));
patternsByLanguage = Collections.unmodifiableMap(patternsByLanguageBuilder);
}
- public String getForcedLanguage() {
- return forcedLanguage;
- }
-
- Map<String, PathPattern[]> patternsByLanguage() {
- return patternsByLanguage;
- }
-
@CheckForNull
String language(Path absolutePath, Path relativePath) {
String detectedLanguage = null;
@@ -112,16 +91,8 @@ public class LanguageDetection {
}
}
}
- if (detectedLanguage != null) {
- return detectedLanguage;
- }
- // Check if deprecated sonar.language is used and we are on a language without declared extensions.
- // Languages without declared suffixes match everything.
- if (forcedLanguage != null && patternsByLanguage.get(forcedLanguage).length == 0) {
- return forcedLanguage;
- }
- return null;
+ return detectedLanguage;
}
private boolean isCandidateForLanguage(Path absolutePath, Path relativePath, String languageKey) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
index dee1c8b1781..af073681944 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
@@ -789,6 +789,8 @@ public class FileSystemMediumTest {
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-symlink");
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
+ .property("sonar.exclusions", "**/*.xoo.measures,**/*.xoo.scm")
+ .property("sonar.test.exclusions", "**/*.xoo.measures,**/*.xoo.scm")
.execute();
assertThat(result.inputFiles()).hasSize(3);
@@ -1071,9 +1073,10 @@ public class FileSystemMediumTest {
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-ignored-file");
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
+ .property("sonar.exclusions", "**/*.xoo.ignore")
+ .property("sonar.test.exclusions", "**/*.xoo.ignore")
.execute();
- assertThat(result.inputFiles()).hasSize(2);
assertThat(result.inputFile("xources/hello/ClassTwo.xoo")).isNull();
assertThat(result.inputFile("testx/ClassTwoTest.xoo")).isNull();
@@ -1087,6 +1090,8 @@ public class FileSystemMediumTest {
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
.property("sonar.scm.exclusions.disabled", "true")
+ .property("sonar.exclusions", "**/*.xoo.ignore")
+ .property("sonar.test.exclusions", "**/*.xoo.ignore")
.execute();
assertThat(result.inputFiles()).hasSize(4);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java
index 7e4a491f6d3..c924cb4c5e5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java
@@ -95,47 +95,6 @@ public class LanguageDetectionTest {
}
@Test
- public void language_with_no_extension() throws Exception {
- // abap does not declare any file extensions.
- // When analyzing an ABAP project, then all source files must be parsed.
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
-
- // No side-effect on non-ABAP projects
- LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isNull();
- assertThat(detectLanguage(detection, "abc.abap")).isNull();
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("java");
-
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "abap");
- detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isEqualTo("abap");
- assertThat(detectLanguage(detection, "abc.txt")).isEqualTo("abap");
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("abap");
- }
-
- @Test
- public void force_language_using_deprecated_property() throws Exception {
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
-
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
- LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isNull();
- assertThat(detectLanguage(detection, "abc.php")).isNull();
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("java");
- assertThat(detectLanguage(detection, "src/abc.java")).isEqualTo("java");
- }
-
- @Test
- public void fail_if_invalid_language() {
- thrown.expect(MessageException.class);
- thrown.expectMessage("You must install a plugin that supports the language 'unknown'");
-
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
- new LanguageDetection(settings.asConfig(), languages);
- }
-
- @Test
public void fail_if_conflicting_language_suffix() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties
index 53aacb54061..60280f9a2c5 100644
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties
+++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties
@@ -4,10 +4,8 @@ sonar.projectVersion=1.0
sonar.modules=java-module,groovy-module
-java-module.sonar.language=java
java-module.sonar.projectBaseDir=.
java-module.sonar.sources=src/main/java
-groovy-module.sonar.language=groovy
groovy-module.sonar.projectBaseDir=.
groovy-module.sonar.sources=src/main/groovy
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
index b07be6f3e6f..a1e8405de78 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
@@ -3,8 +3,6 @@ sonar.projectKey=com.sonarsource.it.samples:multi-modules-sample
sonar.projectName=Sonar :: Integration Tests :: Multi-modules Sample
sonar.projectVersion=1.0-SNAPSHOT
-sonar.language=xoo
-
# Some properties that will be inherited by the modules
sonar.sources=src/main/xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties
index ac18398a604..c641af8798a 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties
@@ -1,3 +1,2 @@
sonar.projectKey=sample-generic-coverage
sonar.sources=xources
-sonar.language=xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties
index 8810e376701..50adabc5bbb 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties
@@ -3,4 +3,3 @@ sonar.projectName=Sample
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties
index 58f27e81f61..51e019b53ee 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties
@@ -2,4 +2,3 @@ sonar.projectKey=sample-with-empty-file
sonar.projectName=Sample With Empty
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
-sonar.language=xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties
index 4e711d750b4..8abf61258ae 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties
@@ -3,5 +3,4 @@ sonar.projectName=Sample
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
sonar.scm.provider=xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties
index 8810e376701..50adabc5bbb 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties
@@ -3,4 +3,3 @@ sonar.projectName=Sample
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
diff --git a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties
index 8810e376701..50adabc5bbb 100644
--- a/sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties
+++ b/sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties
@@ -3,4 +3,3 @@ sonar.projectName=Sample
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo