]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21373 Fix code issues
authorEric Giffon <eric.giffon@sonarsource.com>
Fri, 29 Dec 2023 11:08:51 +0000 (12:08 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 29 Dec 2023 20:02:27 +0000 (20:02 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java
server/sonar-server-common/src/it/java/org/sonar/server/issue/notification/NewIssuesNotificationIT.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotification.java
server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationTest.java

index def64e4e49fb034714a461177084b71281a88271..830b26be4e9d209907e5acb0ad5feb40f77577af 100644 (file)
@@ -28,7 +28,6 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.api.ce.ComputeEngineSide;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.Durations;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
 import org.sonar.ce.task.projectanalysis.component.Component;
@@ -62,27 +61,25 @@ public class NotificationFactory {
   private final TreeRootHolder treeRootHolder;
   private final AnalysisMetadataHolder analysisMetadataHolder;
   private final RuleRepository ruleRepository;
-  private final Durations durations;
   private final IssuesChangesNotificationSerializer issuesChangesSerializer;
   private Map<String, Component> componentsByUuid;
 
   public NotificationFactory(TreeRootHolder treeRootHolder, AnalysisMetadataHolder analysisMetadataHolder,
-    RuleRepository ruleRepository, Durations durations, IssuesChangesNotificationSerializer issuesChangesSerializer) {
+    RuleRepository ruleRepository, IssuesChangesNotificationSerializer issuesChangesSerializer) {
     this.treeRootHolder = treeRootHolder;
     this.analysisMetadataHolder = analysisMetadataHolder;
     this.ruleRepository = ruleRepository;
-    this.durations = durations;
     this.issuesChangesSerializer = issuesChangesSerializer;
   }
 
   public MyNewIssuesNotification newMyNewIssuesNotification(Map<String, UserDto> assigneesByUuid) {
     verifyAssigneesByUuid(assigneesByUuid);
-    return new MyNewIssuesNotification(durations, new DetailsSupplierImpl(assigneesByUuid));
+    return new MyNewIssuesNotification(new DetailsSupplierImpl(assigneesByUuid));
   }
 
   public NewIssuesNotification newNewIssuesNotification(Map<String, UserDto> assigneesByUuid) {
     verifyAssigneesByUuid(assigneesByUuid);
-    return new NewIssuesNotification(durations, new DetailsSupplierImpl(assigneesByUuid));
+    return new NewIssuesNotification(new DetailsSupplierImpl(assigneesByUuid));
   }
 
   public IssuesChangesNotification newIssuesChangesNotification(Set<DefaultIssue> issues, Map<String, UserDto> assigneesByUuid) {
index 318ab7685a28a8c39ed5e83ba4ffd821be925144..5fb3d417e415bc045ca5d377644e67664482b41b 100644 (file)
@@ -82,9 +82,8 @@ public class NotificationFactoryTest {
   @Rule
   public AnalysisMetadataHolderRule analysisMetadata = new AnalysisMetadataHolderRule();
 
-  private Durations durations = new Durations();
   private IssuesChangesNotificationSerializer issuesChangesSerializer = mock(IssuesChangesNotificationSerializer.class);
-  private NotificationFactory underTest = new NotificationFactory(treeRootHolder, analysisMetadata, ruleRepository, durations, issuesChangesSerializer);
+  private NotificationFactory underTest = new NotificationFactory(treeRootHolder, analysisMetadata, ruleRepository, issuesChangesSerializer);
 
   @Test
   public void newMyNewIssuesNotification_throws_NPE_if_assigneesByUuid_is_null() {
@@ -100,20 +99,6 @@ public class NotificationFactoryTest {
       .hasMessage("assigneesByUuid can't be null");
   }
 
-  @Test
-  public void newMyNewIssuesNotification_returns_MyNewIssuesNotification_object_with_the_constructor_Durations() {
-    MyNewIssuesNotification notification = underTest.newMyNewIssuesNotification(emptyMap());
-
-    assertThat(readDurationsField(notification)).isSameAs(durations);
-  }
-
-  @Test
-  public void newNewIssuesNotification_returns_NewIssuesNotification_object_with_the_constructor_Durations() {
-    NewIssuesNotification notification = underTest.newNewIssuesNotification(emptyMap());
-
-    assertThat(readDurationsField(notification)).isSameAs(durations);
-  }
-
   @Test
   public void newMyNewIssuesNotification_DetailsSupplier_getUserNameByUuid_fails_with_NPE_if_uuid_is_null() {
     MyNewIssuesNotification underTest = this.underTest.newMyNewIssuesNotification(emptyMap());
index 04ef41b80c0b1977e9df04c6983351bc4857ce50..e84e702cdd35bc72ffd9fdc09668de83ea30174c 100644 (file)
@@ -25,7 +25,6 @@ import java.util.stream.IntStream;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.Durations;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.issue.IssueDto;
@@ -57,7 +56,7 @@ public class NewIssuesNotificationIT {
   public DbTester db = DbTester.create();
 
   private DetailsSupplier detailsSupplier = mock(DetailsSupplier.class);
-  private NewIssuesNotification underTest = new NewIssuesNotification(new Durations(), detailsSupplier);
+  private NewIssuesNotification underTest = new NewIssuesNotification(detailsSupplier);
 
   @Test
   public void set_project_without_branch() {
index e064f847ca11b2bda9b953022a92813747d5b30f..5da81f47a876d95c03935c974fdc63fd34a3d83f 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.issue.notification;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.Date;
-import java.util.Locale;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.api.config.EmailSettings;
@@ -193,9 +192,4 @@ public abstract class AbstractNewIssuesEmailTemplate implements EmailTemplate {
         .append(NEW_LINE);
     }
   }
-
-  private static Locale getLocale() {
-    return Locale.ENGLISH;
-  }
-
 }
index 5191ff514dc0b37f84477f508f06aa44c77b9324..e18053690f09b6abc800972ab99e3524a532aa4b 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.issue.notification;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import org.sonar.api.utils.Durations;
 import org.sonar.db.user.UserDto;
 
 import static org.sonar.server.issue.notification.AbstractNewIssuesEmailTemplate.FIELD_ASSIGNEE;
@@ -30,8 +29,8 @@ public class MyNewIssuesNotification extends NewIssuesNotification {
 
   public static final String MY_NEW_ISSUES_NOTIF_TYPE = "my-new-issues";
 
-  public MyNewIssuesNotification(Durations durations, DetailsSupplier detailsSupplier) {
-    super(MY_NEW_ISSUES_NOTIF_TYPE, durations, detailsSupplier);
+  public MyNewIssuesNotification(DetailsSupplier detailsSupplier) {
+    super(MY_NEW_ISSUES_NOTIF_TYPE, detailsSupplier);
   }
 
   public MyNewIssuesNotification setAssignee(@Nullable UserDto assignee) {
index 3b7858bf3ef470032e38aa28cbb382d7f55ac126..91513e8f60db3402f618f5281dabd373fb15b5f7 100644 (file)
@@ -30,7 +30,6 @@ import javax.annotation.Nullable;
 import org.sonar.api.notifications.Notification;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.Durations;
 import org.sonar.server.issue.notification.NewIssuesStatistics.Metric;
 
 import static java.util.Objects.requireNonNull;
@@ -51,15 +50,13 @@ public class NewIssuesNotification extends Notification {
   private static final String DOT = ".";
 
   private final transient DetailsSupplier detailsSupplier;
-  private final transient Durations durations;
 
-  public NewIssuesNotification(Durations durations, DetailsSupplier detailsSupplier) {
-    this(TYPE, durations, detailsSupplier);
+  public NewIssuesNotification(DetailsSupplier detailsSupplier) {
+    this(TYPE, detailsSupplier);
   }
 
-  protected NewIssuesNotification(String type, Durations durations, DetailsSupplier detailsSupplier) {
+  protected NewIssuesNotification(String type, DetailsSupplier detailsSupplier) {
     super(type);
-    this.durations = durations;
     this.detailsSupplier = detailsSupplier;
   }
 
index 451ad8ffb59f81d38489ec68d8acaea046f612f7..a746b3b61e86a7d3d9d91bb50c8b6eaeca8a6dce 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.notification;
 
 import org.junit.Test;
-import org.sonar.api.utils.Durations;
 import org.sonar.db.user.UserDto;
 import org.sonar.db.user.UserTesting;
 import org.sonar.server.issue.notification.NewIssuesNotification.DetailsSupplier;
@@ -31,7 +30,7 @@ import static org.sonar.server.issue.notification.AbstractNewIssuesEmailTemplate
 
 public class MyNewIssuesNotificationTest {
 
-  private MyNewIssuesNotification underTest = new MyNewIssuesNotification(mock(Durations.class), mock(DetailsSupplier.class));
+  private MyNewIssuesNotification underTest = new MyNewIssuesNotification(mock(DetailsSupplier.class));
 
   @Test
   public void set_assignee() {