From cab124f7448c71702fb2ff455ca5528ac9bcffcc Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Tue, 7 Jan 2020 11:46:09 +0100 Subject: [PATCH] fix quality flaws --- .../main/java/org/sonar/server/rule/index/RuleIndexer.java | 2 +- .../java/org/sonar/server/hotspot/ws/ChangeStatusAction.java | 4 +++- .../main/java/org/sonar/server/hotspot/ws/SearchAction.java | 4 ++-- .../src/main/java/org/sonar/server/hotspot/ws/ShowAction.java | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndexer.java index 4a4dac17eca..839890d3e68 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndexer.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndexer.java @@ -197,7 +197,7 @@ public class RuleIndexer implements ResilientIndexer { return Optional.of(bulkIndexer.stop()); } - private RuleDoc ruleDocOf(RuleForIndexingDto dto) { + private static RuleDoc ruleDocOf(RuleForIndexingDto dto) { SecurityStandards securityStandards = SecurityStandards.fromSecurityStandards(dto.getSecurityStandards()); if (!securityStandards.getIgnoredSQCategories().isEmpty()) { LOG.warn( diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ChangeStatusAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ChangeStatusAction.java index 8e0ca3a2e14..bd02c0d5f69 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ChangeStatusAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ChangeStatusAction.java @@ -20,6 +20,7 @@ package org.sonar.server.hotspot.ws; import java.util.Objects; +import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.issue.DefaultTransitions; import org.sonar.api.server.ws.Request; @@ -111,6 +112,7 @@ public class ChangeStatusAction implements HotspotsWsAction { } } + @CheckForNull private static String resolutionParam(Request request, String newStatus) { String resolution = request.param(PARAM_RESOLUTION); checkArgument(STATUS_REVIEWED.equals(newStatus) || resolution == null, @@ -122,7 +124,7 @@ public class ChangeStatusAction implements HotspotsWsAction { return resolution; } - private static boolean needStatusUpdate(IssueDto hotspot, String newStatus, String newResolution) { + private static boolean needStatusUpdate(IssueDto hotspot, String newStatus, @Nullable String newResolution) { return !(hotspot.getStatus().equals(newStatus) && Objects.equals(hotspot.getResolution(), newResolution)); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java index f4c2793d228..3676f4abfa4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/SearchAction.java @@ -346,7 +346,7 @@ public class SearchAction implements HotspotsWsAction { return responseBuilder.build(); } - private void formatPaging(SearchResponseData searchResponseData, SearchWsResponse.Builder responseBuilder) { + private static void formatPaging(SearchResponseData searchResponseData, SearchWsResponse.Builder responseBuilder) { Paging paging = searchResponseData.getPaging(); Common.Paging.Builder pagingBuilder = Common.Paging.newBuilder() .setPageIndex(paging.pageIndex()) @@ -356,7 +356,7 @@ public class SearchAction implements HotspotsWsAction { responseBuilder.setPaging(pagingBuilder.build()); } - private void formatHotspots(SearchResponseData searchResponseData, SearchWsResponse.Builder responseBuilder) { + private static void formatHotspots(SearchResponseData searchResponseData, SearchWsResponse.Builder responseBuilder) { List orderedHotspots = searchResponseData.getOrderedHotspots(); if (orderedHotspots.isEmpty()) { return; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java index faaa13a0ac5..9d7d48c5737 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java @@ -135,7 +135,7 @@ public class ShowAction implements HotspotsWsAction { return new Users(assignee, author); } - private void formatHotspot(ShowWsResponse.Builder builder, IssueDto hotspot, Users users) { + private static void formatHotspot(ShowWsResponse.Builder builder, IssueDto hotspot, Users users) { builder.setKey(hotspot.getKey()); ofNullable(hotspot.getStatus()).ifPresent(builder::setStatus); ofNullable(hotspot.getResolution()).ifPresent(builder::setResolution); @@ -154,7 +154,7 @@ public class ShowAction implements HotspotsWsAction { responseBuilder.setCanChangeStatus(hotspotWsSupport.canChangeStatus(components.getProject())); } - private void formatRule(ShowWsResponse.Builder responseBuilder, RuleDefinitionDto ruleDefinitionDto) { + private static void formatRule(ShowWsResponse.Builder responseBuilder, RuleDefinitionDto ruleDefinitionDto) { SecurityStandards securityStandards = SecurityStandards.fromSecurityStandards(ruleDefinitionDto.getSecurityStandards()); SecurityStandards.SQCategory sqCategory = securityStandards.getSqCategory(); HotspotRuleDescription hotspotRuleDescription = HotspotRuleDescription.from(ruleDefinitionDto); -- 2.39.5