]> source.dussan.org Git - sonarqube.git/commitdiff
Clean old remains of the preview mode
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 19 Jun 2019 08:28:41 +0000 (10:28 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 28 Jun 2019 06:45:50 +0000 (08:45 +0200)
sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java
sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/AnalysisContextReportPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java

index e4d59ea1dd82921e5bca72fcc84808f5ccb5ea70..79330b39fe1e408ff9508a1695e981c26b089328 100644 (file)
@@ -34,8 +34,6 @@ public final class ComponentKeys {
    */
   private static final String VALID_PROJECT_KEY_REGEXP = "[^\\p{javaWhitespace}]+";
 
-  private static final String VALID_PROJECT_KEY_ISSUES_MODE_REGEXP = "[\\p{Alnum}\\-_.:/]*[\\p{Alpha}\\-_.:/]+[\\p{Alnum}\\-_.:/]*";
-
   /*
    * Allowed characters are alphanumeric, '-', '_', '.' and '/'
    */
@@ -78,26 +76,6 @@ public final class ComponentKeys {
     checkArgument(isValidProjectKey(keyCandidate), "Malformed key for '%s'. %s", keyCandidate, "Project key cannot be empty nor contain whitespaces.");
   }
 
-  /**
-   * <p>Test if given parameter is valid for a project. Valid format is:</p>
-   * <ul>
-   * <li>Allowed characters:
-   * <ul>
-   * <li>Uppercase ASCII letters A-Z</li>
-   * <li>Lowercase ASCII letters a-z</li>
-   * <li>ASCII digits 0-9</li>
-   * <li>Punctuation signs dash '-', underscore '_', period '.', colon ':' and slash '/'</li>
-   * </ul>
-   * </li>
-   * <li>At least one non-digit</li>
-   * </ul>
-   *
-   * @return <code>true</code> if <code>keyCandidate</code> can be used for a project in issues mode
-   */
-  public static boolean isValidProjectKeyIssuesMode(String keyCandidate) {
-    return keyCandidate.matches(VALID_PROJECT_KEY_ISSUES_MODE_REGEXP);
-  }
-
   /**
    * <p>Test if given parameter is valid for a branch. Valid format is:</p>
    * <ul>
index 7f555664e298ddf57f3dacd99f5f9de3506377f0..5187d09bd24932f95750d88aad57631ea4beca21 100644 (file)
@@ -60,16 +60,6 @@ public class ComponentKeysTest {
     assertThat(ComponentKeys.isValidProjectKey("ab ")).isFalse();
   }
 
-  @Test
-  public void isValidModuleKeyIssuesMode() {
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("")).isFalse();
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("abc")).isTrue();
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("0123")).isFalse();
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("ab 12")).isFalse();
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("ab_12")).isTrue();
-    assertThat(ComponentKeys.isValidProjectKeyIssuesMode("ab/12")).isTrue();
-  }
-
   @Test
   public void isValidBranchKey() {
     assertThat(ComponentKeys.isValidLegacyBranch("")).isTrue();
index 42f9b0ee5a8be433795fa965e51e5d17a2533f4c..25780591679b34afb5600d1c50c3810c2412268b 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.TreeSet;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.internal.AbstractProjectOrModule;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
@@ -53,16 +52,14 @@ public class AnalysisContextReportPublisher {
   private static final int MAX_WIDTH = 1000;
   private final ScannerPluginRepository pluginRepo;
   private final ProjectServerSettings projectServerSettings;
-  private final AnalysisMode mode;
   private final System2 system;
   private final GlobalServerSettings globalServerSettings;
   private final InputModuleHierarchy hierarchy;
   private final InputComponentStore store;
 
-  public AnalysisContextReportPublisher(ProjectServerSettings projectServerSettings, AnalysisMode mode, ScannerPluginRepository pluginRepo, System2 system,
+  public AnalysisContextReportPublisher(ProjectServerSettings projectServerSettings, ScannerPluginRepository pluginRepo, System2 system,
     GlobalServerSettings globalServerSettings, InputModuleHierarchy hierarchy, InputComponentStore store) {
     this.projectServerSettings = projectServerSettings;
-    this.mode = mode;
     this.pluginRepo = pluginRepo;
     this.system = system;
     this.globalServerSettings = globalServerSettings;
@@ -71,9 +68,6 @@ public class AnalysisContextReportPublisher {
   }
 
   public void init(ScannerReportWriter writer) {
-    if (mode.isIssues()) {
-      return;
-    }
     File analysisLog = writer.getFileStructure().analysisLog();
     try (BufferedWriter fileWriter = Files.newBufferedWriter(analysisLog.toPath(), StandardCharsets.UTF_8)) {
       writePlugins(fileWriter);
index fae56336d344071907f00b25a2acc3d5cd4d2ce7..f639e0f02fda0f59ea29f1d8aabff65b987d159d 100644 (file)
@@ -25,7 +25,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.utils.MessageException;
@@ -49,32 +48,26 @@ import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_KEY;
  * @since 3.6
  */
 public class ProjectReactorValidator {
-  private final AnalysisMode mode;
   private final GlobalConfiguration settings;
 
   // null = branch plugin is not available
   @Nullable
   private final BranchParamsValidator branchParamsValidator;
 
-  public ProjectReactorValidator(AnalysisMode mode, GlobalConfiguration settings, @Nullable BranchParamsValidator branchParamsValidator) {
-    this.mode = mode;
+  public ProjectReactorValidator(GlobalConfiguration settings, @Nullable BranchParamsValidator branchParamsValidator) {
     this.settings = settings;
     this.branchParamsValidator = branchParamsValidator;
   }
 
-  public ProjectReactorValidator(AnalysisMode mode, GlobalConfiguration settings) {
-    this(mode, settings, null);
+  public ProjectReactorValidator(GlobalConfiguration settings) {
+    this(settings, null);
   }
 
   public void validate(ProjectReactor reactor) {
     List<String> validationMessages = new ArrayList<>();
 
     for (ProjectDefinition moduleDef : reactor.getProjects()) {
-      if (mode.isIssues()) {
-        validateModuleIssuesMode(moduleDef, validationMessages);
-      } else {
-        validateModule(moduleDef, validationMessages);
-      }
+      validateModule(moduleDef, validationMessages);
     }
 
     String deprecatedBranchName = reactor.getRoot().getBranch();
@@ -109,13 +102,6 @@ public class ProjectReactorValidator {
         + "See %s for more information.", param, BRANCHES_DOC_LINK)));
   }
 
-  private static void validateModuleIssuesMode(ProjectDefinition moduleDef, List<String> validationMessages) {
-    if (!ComponentKeys.isValidProjectKeyIssuesMode(moduleDef.getKey())) {
-      validationMessages.add(format("\"%s\" is not a valid project or module key. "
-        + "Allowed characters in issues mode are alphanumeric, '-', '_', '.', '/' and ':', with at least one non-digit.", moduleDef.getKey()));
-    }
-  }
-
   private static void validateModule(ProjectDefinition moduleDef, List<String> validationMessages) {
     if (!ComponentKeys.isValidProjectKey(moduleDef.getKey())) {
       validationMessages.add(format("\"%s\" is not a valid project or module key. It cannot be empty nor contain whitespaces.", moduleDef.getKey()));
index b883a266c3a068672dd68cae17046deda20fe19d..22c8528301fb4e5cec6b16ffa5131c911e311818 100644 (file)
@@ -23,9 +23,7 @@ import com.google.common.collect.ImmutableMap;
 import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -33,7 +31,6 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
@@ -69,7 +66,6 @@ public class AnalysisContextReportPublisherTest {
 
   private ScannerPluginRepository pluginRepo = mock(ScannerPluginRepository.class);
   private AnalysisContextReportPublisher publisher;
-  private AnalysisMode analysisMode = mock(AnalysisMode.class);
   private System2 system2;
   private GlobalServerSettings globalServerSettings;
   private InputModuleHierarchy hierarchy;
@@ -85,7 +81,7 @@ public class AnalysisContextReportPublisherTest {
     hierarchy = mock(InputModuleHierarchy.class);
     store = mock(InputComponentStore.class);
     projectServerSettings = mock(ProjectServerSettings.class);
-    publisher = new AnalysisContextReportPublisher(projectServerSettings, analysisMode, pluginRepo, system2, globalServerSettings, hierarchy, store);
+    publisher = new AnalysisContextReportPublisher(projectServerSettings, pluginRepo, system2, globalServerSettings, hierarchy, store);
   }
 
   @Test
@@ -106,16 +102,6 @@ public class AnalysisContextReportPublisherTest {
     verifyZeroInteractions(system2);
   }
 
-  @Test
-  public void shouldNotDumpInIssuesMode() throws Exception {
-    when(analysisMode.isIssues()).thenReturn(true);
-
-    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
-    publisher.init(writer);
-
-    assertThat(writer.getFileStructure().analysisLog()).doesNotExist();
-  }
-
   @Test
   public void dumpServerSideGlobalProps() throws Exception {
     logTester.setLevel(LoggerLevel.DEBUG);
index 5f817757192b540f8c9495c3fa5015ea2609693b..464ea32f912c03aa4a1f7c29dc96d5073d45c9c0 100644 (file)
@@ -31,7 +31,6 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.utils.MessageException;
@@ -51,10 +50,9 @@ public class ProjectReactorValidatorTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
-  private AnalysisMode mode = mock(AnalysisMode.class);
   private GlobalConfiguration settings = mock(GlobalConfiguration.class);
   private ProjectInfo projectInfo = mock(ProjectInfo.class);
-  private ProjectReactorValidator underTest = new ProjectReactorValidator(mode, settings);
+  private ProjectReactorValidator underTest = new ProjectReactorValidator(settings);
 
   @Before
   public void prepare() {
@@ -87,12 +85,6 @@ public class ProjectReactorValidatorTest {
     };
   }
 
-  @Test
-  public void allow_slash_issues_mode() {
-    when(mode.isIssues()).thenReturn(true);
-    underTest.validate(createProjectReactor("project/key"));
-  }
-
   @Test
   public void fail_with_invalid_key() {
     ProjectReactor reactor = createProjectReactor("  ");