diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-12-09 22:02:28 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-12-09 22:02:28 +0100 |
commit | f0cbff8e9697dd5cb4999eee5e6f92871eacdfe2 (patch) | |
tree | 300024d21d9653b784d0eca86d9b818631f3612e /sonar-core/src/main | |
parent | 9b8d4d064f0c719ae1a96fc2140912a90b367706 (diff) | |
download | sonarqube-f0cbff8e9697dd5cb4999eee5e6f92871eacdfe2.tar.gz sonarqube-f0cbff8e9697dd5cb4999eee5e6f92871eacdfe2.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-core/src/main')
3 files changed, 43 insertions, 36 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java index 5c0a63317a1..4bf4f2c7301 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java @@ -57,27 +57,39 @@ public class RuleI18nManager implements RuleI18n, ServerExtension, BatchExtensio @Override public void stop() { - + // nothing to do } + /** + * @deprecated in 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 + */ @Override @Deprecated public String getName(String repositoryKey, String ruleKey, Locale locale) { return getName(repositoryKey, ruleKey); } + /** + * @deprecated in 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 + */ @Override @Deprecated public String getName(Rule rule, Locale locale) { return getName(rule); } + /** + * @deprecated in 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 + */ @Override @Deprecated public String getDescription(String repositoryKey, String ruleKey, Locale locale) { return getDescription(repositoryKey, ruleKey); } + /** + * @deprecated in 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 + */ @Override @Deprecated public String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale) { diff --git a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java index 4203c1dcb95..9af55101a5a 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/IssueNotifications.java @@ -34,14 +34,11 @@ import org.sonar.api.resources.Project; import org.sonar.api.rule.Severity; import org.sonar.api.rules.Rule; import org.sonar.api.utils.DateUtils; -import org.sonar.core.i18n.RuleI18nManager; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.io.Serializable; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -53,11 +50,9 @@ import java.util.Map.Entry; public class IssueNotifications implements BatchComponent, ServerComponent { private final NotificationManager notificationsManager; - private final RuleI18nManager ruleI18n; - public IssueNotifications(NotificationManager notificationsManager, RuleI18nManager ruleI18n) { + public IssueNotifications(NotificationManager notificationsManager) { this.notificationsManager = notificationsManager; - this.ruleI18n = ruleI18n; } public Notification sendNewIssues(Project project, IssuesBySeverity newIssues) { @@ -66,7 +61,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent { .setFieldValue("projectDate", DateUtils.formatDateTime(project.getAnalysisDate())) .setFieldValue("count", String.valueOf(newIssues.size())); for (String severity : Severity.ALL) { - notification.setFieldValue("count-"+ severity, String.valueOf(newIssues.issues(severity))); + notification.setFieldValue("count-" + severity, String.valueOf(newIssues.issues(severity))); } notificationsManager.scheduleForSending(notification); return notification; @@ -103,7 +98,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent { @CheckForNull private Notification createChangeNotification(DefaultIssue issue, IssueChangeContext context, Rule rule, Component project, - @Nullable Component component, @Nullable String comment) { + @Nullable Component component, @Nullable String comment) { Notification notification = null; if (comment != null || issue.mustSendNotifications()) { FieldDiffs currentChange = issue.currentChange(); @@ -141,11 +136,7 @@ public class IssueNotifications implements BatchComponent, ServerComponent { if (rule == null) { return null; } - String name = ruleI18n.getName(rule.getRepositoryKey(), rule.getKey(), Locale.ENGLISH); - if (name == null) { - name = rule.getName(); - } - return name; + return rule.getName(); } private Notification newNotification(Component project, String key) { diff --git a/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java b/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java index 39105951297..5cec83e94b7 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/workflow/IssueWorkflow.java @@ -45,15 +45,20 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable @Override public void start() { - machine = StateMachine.builder() - + StateMachine.Builder builder = StateMachine.builder() // order is important for UI - .states(Issue.STATUS_OPEN, Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED) + .states(Issue.STATUS_OPEN, Issue.STATUS_CONFIRMED, Issue.STATUS_REOPENED, Issue.STATUS_RESOLVED, Issue.STATUS_CLOSED); - .transition(Transition.builder(DefaultTransitions.CONFIRM) - .from(Issue.STATUS_OPEN).to(Issue.STATUS_CONFIRMED) - .functions(new SetResolution(null)) - .build()) + buildManualTransitions(builder); + buildAutomaticTransitions(builder); + machine = builder.build(); + } + + private void buildManualTransitions(StateMachine.Builder builder) { + builder.transition(Transition.builder(DefaultTransitions.CONFIRM) + .from(Issue.STATUS_OPEN).to(Issue.STATUS_CONFIRMED) + .functions(new SetResolution(null)) + .build()) .transition(Transition.builder(DefaultTransitions.CONFIRM) .from(Issue.STATUS_REOPENED).to(Issue.STATUS_CONFIRMED) .functions(new SetResolution(null)) @@ -84,7 +89,7 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable .functions(new SetResolution(null), new SetCloseDate(false)) .build()) - // resolve as false-positive + // resolve as false-positive .transition(Transition.builder(DefaultTransitions.FALSE_POSITIVE) .from(Issue.STATUS_OPEN).to(Issue.STATUS_RESOLVED) .functions(new SetResolution(Issue.RESOLUTION_FALSE_POSITIVE), SetAssignee.UNASSIGN) @@ -99,17 +104,17 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable .from(Issue.STATUS_CONFIRMED).to(Issue.STATUS_RESOLVED) .functions(new SetResolution(Issue.RESOLUTION_FALSE_POSITIVE), SetAssignee.UNASSIGN) .requiredProjectPermission(UserRole.ISSUE_ADMIN) - .build()) - - // automatic transitions + .build()); + } - // Close the "end of life" issues (disabled/deleted rule, deleted component) - .transition(Transition.builder("automaticclose") - .from(Issue.STATUS_OPEN).to(Issue.STATUS_CLOSED) - .conditions(new IsEndOfLife(true)) - .functions(new SetEndOfLifeResolution(), new SetCloseDate(true)) - .automatic() - .build()) + private void buildAutomaticTransitions(StateMachine.Builder builder) { + // Close the "end of life" issues (disabled/deleted rule, deleted component) + builder.transition(Transition.builder("automaticclose") + .from(Issue.STATUS_OPEN).to(Issue.STATUS_CLOSED) + .conditions(new IsEndOfLife(true)) + .functions(new SetEndOfLifeResolution(), new SetCloseDate(true)) + .automatic() + .build()) .transition(Transition.builder("automaticclose") .from(Issue.STATUS_REOPENED).to(Issue.STATUS_CLOSED) .conditions(new IsEndOfLife(true)) @@ -135,16 +140,15 @@ public class IssueWorkflow implements BatchComponent, ServerComponent, Startable .automatic() .build()) - // Reopen issues that are marked as resolved but that are still alive. - // Manual issues are kept resolved. + // Reopen issues that are marked as resolved but that are still alive. + // Manual issues are kept resolved. .transition(Transition.builder("automaticreopen") .from(Issue.STATUS_RESOLVED).to(Issue.STATUS_REOPENED) .conditions(new IsEndOfLife(false), new HasResolution(Issue.RESOLUTION_FIXED), new IsManual(false)) .functions(new SetResolution(null), new SetCloseDate(false)) .automatic() .build() - ) - .build(); + ); } @Override |