diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-02 22:32:30 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-02 22:32:30 +0200 |
commit | 787529a7ec4a567a31b375f76954ea31714a7c86 (patch) | |
tree | effd57e9cfba2211aebb7f6419796e49b40dc1f6 /plugins/sonar-core-plugin | |
parent | 7f99c3f633353a98878103d5a5c99001745ce422 (diff) | |
download | sonarqube-787529a7ec4a567a31b375f76954ea31714a7c86.tar.gz sonarqube-787529a7ec4a567a31b375f76954ea31714a7c86.zip |
Fix some quality flaws
Diffstat (limited to 'plugins/sonar-core-plugin')
2 files changed, 13 insertions, 13 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java index 3c79baff3f9..3fb852f651f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewNotifications.java @@ -65,7 +65,7 @@ public class ReviewNotifications implements BatchExtension { .setFieldValue("assignee", getAssignee(review)); } - private @Nullable String getCreator(ReviewDto review) { + private String getCreator(ReviewDto review) { if (review.getUserId() == null) { // no creator and in fact this should never happen in real-life, however happens during unit tests return null; } @@ -73,7 +73,7 @@ public class ReviewNotifications implements BatchExtension { return user != null ? user.getLogin() : null; } - private @Nullable String getAssignee(ReviewDto review) { + private String getAssignee(ReviewDto review) { if (review.getAssigneeId() == null) { // not assigned return null; } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java index 9fc97e67ba8..3e27ee2f61b 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewWorkflowDecorator.java @@ -107,12 +107,10 @@ public class ReviewWorkflowDecorator implements Decorator { for (ReviewDto review : openReviews) { Violation violation = violationsByPermanentId.get(review.getViolationPermanentId()); - if (violation != null) { - if (!hasUpToDateInformation(review, violation)) { - review.setLine(violation.getLineId()); - review.setTitle(violation.getMessage()); - updated.add(review); - } + if (violation != null && !hasUpToDateInformation(review, violation)) { + review.setLine(violation.getLineId()); + review.setTitle(violation.getMessage()); + updated.add(review); } } } @@ -132,11 +130,7 @@ public class ReviewWorkflowDecorator implements Decorator { } private void closeResolvedStandardViolations(Collection<ReviewDto> openReviews, List<Violation> violations, Project project, Resource resource, Set<ReviewDto> updated) { - Set<Integer> violationIds = Sets.newHashSet(Collections2.transform(violations, new Function<Violation, Integer>() { - public Integer apply(Violation violation) { - return violation.getPermanentId(); - } - })); + Set<Integer> violationIds = Sets.newHashSet(Collections2.transform(violations, new ViolationToPermanentIdFunction())); for (ReviewDto openReview : openReviews) { if (!openReview.isManualViolation() && !violationIds.contains(openReview.getViolationPermanentId())) { @@ -168,4 +162,10 @@ public class ReviewWorkflowDecorator implements Decorator { review.setResolution(null); review.setUpdatedAt(new Date()); } + + private static final class ViolationToPermanentIdFunction implements Function<Violation, Integer> { + public Integer apply(Violation violation) { + return violation.getPermanentId(); + } + } } |