]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11449 Drop deprecated property sonar.language
authorBenoît Gianinetti <benoit.gianinetti@sonarsource.com>
Thu, 14 Mar 2019 14:07:47 +0000 (15:07 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 19 Mar 2019 19:21:28 +0000 (20:21 +0100)
16 files changed:
server/sonar-docs/src/pages/analysis/analysis-parameters.md
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
sonar-plugin-api/test-resources/org/sonar/api/filesystem/sample-with-symlink/sonar-project.properties
sonar-plugin-api/test-resources/org/sonar/api/filesystem/sample/sonar-project.properties
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/LanguageDetectionTest.java
sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/ProjectReactorBuilderTest/multi-language-definitions-all-in-root/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/multi-modules-sample/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-coverage/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-generic-test-exec/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-empty-file/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-ignored-file/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample-with-symlink/sonar-project.properties
sonar-scanner-engine/test-resources/mediumtest/xoo/sample/sonar-project.properties

index 42ea1f02e8973237797f07bc0bf02b78cec61362..a73703a23e61e02d7a415755eb135bbf55b2fe0a 100644 (file)
@@ -99,7 +99,6 @@ Key | Description | Default
 Key | Description
 ---|----|---
 `sonar.branch` **![](/images/cross.svg)Deprecated since SQ 6.7** | _The Developer Edition provides fuller-featured branch functionality._ Manage SCM branches. Two branches of the same project are considered to be different projects in SonarQube. As a consequence issues found in a project A in a branch B1 are not linked to issues found for this project A in a branch B2. There is no way to automatically resolve issues from B2 when they are resolved in B1 as again A-B1 & A-B2 are considered separated projects. 
-`sonar.language` **![](/images/cross.svg)Deprecated since SQ 4.5** | Set the language of the source code to analyze. Browse the Plugin Library page to get the list of all available languages. If not set, a multi-language analysis will be triggered. 
-`sonar.profile` **![](/images/cross.svg)Deprecated since SQ 4.5** | Override the profile to be used. This should be set on a per-language basis through the UI instead.
+`sonar.profile` **![](/images/cross.svg)Deprecated since SQ 4.5** | Override the profile to be used. This should be set on a per-langauge basis through the UI instead.
 `sonar.links.scm_dev` **![](/images/cross.svg)Deprecated since SQ 7.1** | Developer connection. | `<scm><developerConnection>` for Maven projects
 <!-- /sonarqube -->
index 1fbd5925c0e278cb3db78fe197fb10c6910ecff8..4f2dbe91fa1e1e83ef957179b235daf074f54155 100644 (file)
@@ -180,12 +180,6 @@ public interface CoreProperties {
    */
   String LONG_LIVED_BRANCHES_REGEX = "sonar.branch.longLivedBranches.regex";
 
-  /**
-   * @deprecated since 4.2 projects are now multi-language
-   */
-  @Deprecated
-  String PROJECT_LANGUAGE_PROPERTY = "sonar.language";
-
   /* Exclusions */
   String PROJECT_INCLUSIONS_PROPERTY = "sonar.inclusions";
   String PROJECT_EXCLUSIONS_PROPERTY = "sonar.exclusions";
index 8810e37670198da863d7d0792bcb8500406bc930..50adabc5bbb299ff1354e242f8fa679726261387 100644 (file)
@@ -3,4 +3,3 @@ sonar.projectName=Sample
 sonar.projectVersion=0.1-SNAPSHOT
 sonar.sources=xources
 sonar.tests=testx
-sonar.language=xoo
index bb0a550f4523c70791db8a3931ea25250a4fcc69..982d413a71fd7f4dcd690d5d7fd28523ca9189de 100644 (file)
@@ -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);
index 1b74abd4aa926ba0295c0777e648bd11944b164f..57fbb86e23d39b8bab80d11e81583a3a0c5c97e0 100644 (file)
@@ -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) {
index dee1c8b17818a45d6fa5f717a27b23adeded0317..af07368194464f9d6f20b909954e695866e74ea9 100644 (file)
@@ -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);
index 7e4a491f6d3a2b38a2c31c35ae2b3c7e8dc4c99d..c924cb4c5e5cfa3f3f1eb5c3d6551793bebd003e 100644 (file)
@@ -94,47 +94,6 @@ public class LanguageDetectionTest {
     assertThat(detectLanguage(detection, "abc.abap")).isEqualTo("abap");
   }
 
-  @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")));
index 53aacb54061ad85ff06f1eaacc83f4fcd463bf73..60280f9a2c5dfe0ff3bb213cddfd2df5b0637f87 100644 (file)
@@ -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
index b07be6f3e6f8dccea17637bc43451d5c0ee508e9..a1e8405de7849c6c70bd61d237789230c929c785 100644 (file)
@@ -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
  
index 58f27e81f614145e48559d3357a7952617e96bd0..51e019b53eef70ee1d885358653e44af8ed02643 100644 (file)
@@ -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
index 4e711d750b42d05cb6c7df489a34a334443b42ce..8abf61258ae0a8ba8cf3102aa5add47d0bb19e22 100644 (file)
@@ -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
index 8810e37670198da863d7d0792bcb8500406bc930..50adabc5bbb299ff1354e242f8fa679726261387 100644 (file)
@@ -3,4 +3,3 @@ sonar.projectName=Sample
 sonar.projectVersion=0.1-SNAPSHOT
 sonar.sources=xources
 sonar.tests=testx
-sonar.language=xoo
index 8810e37670198da863d7d0792bcb8500406bc930..50adabc5bbb299ff1354e242f8fa679726261387 100644 (file)
@@ -3,4 +3,3 @@ sonar.projectName=Sample
 sonar.projectVersion=0.1-SNAPSHOT
 sonar.sources=xources
 sonar.tests=testx
-sonar.language=xoo