From: Eric Giffon Date: Fri, 29 Dec 2023 11:08:51 +0000 (+0100) Subject: SONAR-21373 Fix code issues X-Git-Tag: 10.4.0.87286~240 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d1076fb36bf64a18542bdbd0fe4a794737d719b7;p=sonarqube.git SONAR-21373 Fix code issues --- diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java index def64e4e49f..830b26be4e9 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactory.java @@ -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 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 assigneesByUuid) { verifyAssigneesByUuid(assigneesByUuid); - return new MyNewIssuesNotification(durations, new DetailsSupplierImpl(assigneesByUuid)); + return new MyNewIssuesNotification(new DetailsSupplierImpl(assigneesByUuid)); } public NewIssuesNotification newNewIssuesNotification(Map assigneesByUuid) { verifyAssigneesByUuid(assigneesByUuid); - return new NewIssuesNotification(durations, new DetailsSupplierImpl(assigneesByUuid)); + return new NewIssuesNotification(new DetailsSupplierImpl(assigneesByUuid)); } public IssuesChangesNotification newIssuesChangesNotification(Set issues, Map assigneesByUuid) { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java index 318ab7685a2..5fb3d417e41 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java @@ -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()); diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/issue/notification/NewIssuesNotificationIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/issue/notification/NewIssuesNotificationIT.java index 04ef41b80c0..e84e702cdd3 100644 --- a/server/sonar-server-common/src/it/java/org/sonar/server/issue/notification/NewIssuesNotificationIT.java +++ b/server/sonar-server-common/src/it/java/org/sonar/server/issue/notification/NewIssuesNotificationIT.java @@ -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() { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java index e064f847ca1..5da81f47a87 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/AbstractNewIssuesEmailTemplate.java @@ -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; - } - } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotification.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotification.java index 5191ff514dc..e18053690f0 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotification.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/MyNewIssuesNotification.java @@ -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) { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java index 3b7858bf3ef..91513e8f60d 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java @@ -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; } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationTest.java index 451ad8ffb59..a746b3b61e8 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationTest.java @@ -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() {