]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA fix code smells
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Wed, 12 Oct 2022 15:12:27 +0000 (17:12 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 13 Oct 2022 20:03:18 +0000 (20:03 +0000)
server/sonar-webserver-auth/src/main/java/org/sonar/server/user/UserUpdater.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java

index 594de62f0a279e84d332da9a91c5c135b9e821c5..beca143614a271d14d6b1d2b189d17faf9875c26 100644 (file)
@@ -68,7 +68,7 @@ public class UserUpdater {
   private static final String NAME_PARAM = "Name";
   private static final String EMAIL_PARAM = "Email";
   private static final Pattern START_WITH_SPECIFIC_AUTHORIZED_CHARACTERS = Pattern.compile("^[\\.\\-_@].*$");
-  private static final Pattern CONTAINS_ONLY_AUTHORIZED_CHARACTERS = Pattern.compile("\\A\\w[\\w\\.\\-_@]+\\z");
+  private static final Pattern CONTAINS_ONLY_AUTHORIZED_CHARACTERS = Pattern.compile("\\A\\w[\\w\\.\\-@]+\\z");
 
   public static final int LOGIN_MIN_LENGTH = 2;
   public static final int LOGIN_MAX_LENGTH = 255;
index bd9b077a72704cc1d3dd00396610e481a49ac17a..7763abaa469582c29c58159dfa0376318f86e095 100644 (file)
@@ -325,7 +325,6 @@ public class UserUpdaterCreateTest {
       .hasMessage("Login is too short (minimum is 2 characters)");
   }
 
-
   @Test
   public void fail_to_create_user_login_start_with_underscore() {
     assertThatThrownBy(() -> {
@@ -341,6 +340,21 @@ public class UserUpdaterCreateTest {
       .hasMessage("Login should not start with .-_@");
   }
 
+  @Test
+  public void create_user_login_contains_underscore() {
+    createDefaultGroup();
+    String login = "name_with_underscores";
+    NewUser newUser = NewUser.builder()
+      .setLogin(login)
+      .setName("Marius")
+      .setEmail("marius@mail.com")
+      .setPassword("password")
+      .build();
+
+    underTest.createAndCommit(db.getSession(), newUser, u -> {});
+
+    assertThat(dbClient.userDao().selectByLogin(session, login)).isNotNull();
+  }
 
   @Test
   public void fail_to_create_user_with_too_long_login() {
index 319e444026dee53f18a3dbca6a26a1d13b53ce70..ddd52ec73a1a53ee7aabbcc4f3be17d9dd7abd7b 100644 (file)
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Optional;
 import java.util.zip.GZIPInputStream;
-import java.util.zip.InflaterInputStream;
 import org.sonar.api.scanner.fs.InputProject;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.log.Logger;
index e648fe77c79f3aff85dca97753d463db822990d9..1219428a30524c9e62952d2f33dd5f366b573c4a 100644 (file)
@@ -79,7 +79,8 @@ public class ProjectFileIndexer {
   private ProgressReport progressReport;
 
   public ProjectFileIndexer(InputComponentStore componentStore, ProjectExclusionFilters exclusionFilters,
-    SonarGlobalPropertiesFilter sonarGlobalPropertiesFilter, InputModuleHierarchy inputModuleHierarchy, GlobalConfiguration globalConfig, GlobalServerSettings globalServerSettings, ProjectServerSettings projectServerSettings,
+    SonarGlobalPropertiesFilter sonarGlobalPropertiesFilter, InputModuleHierarchy inputModuleHierarchy,
+    GlobalConfiguration globalConfig, GlobalServerSettings globalServerSettings, ProjectServerSettings projectServerSettings,
     FileIndexer fileIndexer, ProjectCoverageAndDuplicationExclusions projectCoverageAndDuplicationExclusions, ScmConfiguration scmConfiguration) {
     this.componentStore = componentStore;
     this.sonarGlobalPropertiesFilter = sonarGlobalPropertiesFilter;