]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 2 Mar 2016 09:33:41 +0000 (10:33 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 2 Mar 2016 09:33:57 +0000 (10:33 +0100)
15 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueCounter.java
server/sonar-server/src/main/java/org/sonar/server/computation/issue/commonrule/CommentDensityRule.java
server/sonar-server/src/main/java/org/sonar/server/issue/IssuesFinderSort.java
server/sonar-server/src/main/java/org/sonar/server/issue/filter/IssueFilterService.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationDao.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/main/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationDispatcher.java
server/sonar-server/src/main/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcher.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
server/sonar-server/src/main/java/org/sonar/server/ws/WebServicesWs.java
sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java
sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java
sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java

index 75925943942f98bf719116cdf96f561d06aedf9d..3373eb62bd3868afe2e893d59027cf80e0687e9f 100644 (file)
@@ -184,7 +184,7 @@ public class IssueCounter extends IssueVisitor {
     if (!periodsHolder.getPeriods().isEmpty()) {
       Double[] unresolvedVariations = new Double[PeriodsHolder.MAX_NUMBER_OF_PERIODS];
       for (Period period : periodsHolder.getPeriods()) {
-        unresolvedVariations[period.getIndex() - 1] = new Double(currentCounters.counterForPeriod(period.getIndex()).unresolved);
+        unresolvedVariations[period.getIndex() - 1] = (double) currentCounters.counterForPeriod(period.getIndex()).unresolved;
       }
       measureRepository.add(component, metricRepository.getByKey(NEW_VIOLATIONS_KEY), Measure.newMeasureBuilder()
         .setVariations(new MeasureVariations(unresolvedVariations))
index c3dcbf831a5fbaffce7ebf9406d3a8840117d4c8..59766be6e0d326817fc15e9520688156a8525e93 100644 (file)
@@ -71,7 +71,8 @@ public class CommentDensityRule extends CommonRule {
     return min;
   }
 
-  private static CommonRuleIssue generateIssue(Optional<Measure> commentDensityMeasure, Optional<Measure> commentLinesMeasure, Optional<Measure> nclocMeasure, double minCommentDensity) {
+  private static CommonRuleIssue generateIssue(Optional<Measure> commentDensityMeasure, Optional<Measure> commentLinesMeasure,
+                                               Optional<Measure> nclocMeasure, double minCommentDensity) {
     int commentLines = commentLinesMeasure.isPresent() ? commentLinesMeasure.get().getIntValue() : 0;
     int ncloc = nclocMeasure.get().getIntValue();
     int minExpectedCommentLines = (int) Math.ceil(minCommentDensity * ncloc / (100 - minCommentDensity));
index e90fe003eb28bcbfd73eeaaf78c2723ef49411b7..f1d6ace71a8ceae823f2b079647432836280ae85 100644 (file)
@@ -50,7 +50,7 @@ class IssuesFinderSort {
     return issues;
   }
 
-  private IssueProcessor getIssueProcessor(String sort) {
+  private static IssueProcessor getIssueProcessor(String sort) {
     if (IssueQuery.SORT_BY_ASSIGNEE.equals(sort)) {
       return new AssigneeSortIssueProcessor();
     }
index a03c55119e1c0512436cc72d84fef9b0ebc384c9..74cff9ae97cc9f8f04870f82841582517b7339df 100644 (file)
@@ -317,7 +317,7 @@ public class IssueFilterService {
     return authorizationDao.selectGlobalPermissions(user).contains(GlobalPermissions.SYSTEM_ADMIN);
   }
 
-  private IssueFilterResult createIssueFilterResult(SearchResult<IssueDoc> issues, SearchOptions options) {
+  private static IssueFilterResult createIssueFilterResult(SearchResult<IssueDoc> issues, SearchOptions options) {
     Paging paging = Paging.forPageIndex(options.getPage()).withPageSize(options.getLimit()).andTotal((int) issues.getTotal());
     return new IssueFilterResult(issues.getDocs(), paging);
   }
index 051de066299bd929074e05662fcb86a5c9e65f29..d61b0ff76a2c717cdf3d632191e7cdfeaf179a27 100644 (file)
@@ -182,7 +182,7 @@ public class IssueAuthorizationDao {
     return stmt;
   }
 
-  private void processRow(ResultSet rs, Map<String, Dto> dtosByProjectUuid) throws SQLException {
+  private static void processRow(ResultSet rs, Map<String, Dto> dtosByProjectUuid) throws SQLException {
     String projectUuid = rs.getString(1);
     String userLogin = rs.getString(2);
     String group = rs.getString(3);
index 37ac9f4af75d13a684023079ec4a07b45793b2b8..f143eec779135bb1f9658503e6078a7048d62ab8 100644 (file)
@@ -541,7 +541,7 @@ public class IssueIndex extends BaseIndex {
       .subAggregation(facetTopAggregation);
   }
 
-  private Collection<String> escapeValuesForFacetInclusion(@Nullable Collection<String> values) {
+  private static Collection<String> escapeValuesForFacetInclusion(@Nullable Collection<String> values) {
     return values == null ? Arrays.<String>asList() : Collections2.transform(values, new Function<String, String>() {
       @Override
       public String apply(String input) {
index b80490b26e4cb65ac90425897179f4568e240516..e19336c5ea0b26434b852f15058c1e70229373b5 100644 (file)
@@ -76,7 +76,7 @@ public class ChangesOnMyIssueNotificationDispatcher extends NotificationDispatch
     }
   }
 
-  private void addUserToContextIfSubscribed(Context context, @Nullable String user, Multimap<String, NotificationChannel> subscribedRecipients) {
+  private static void addUserToContextIfSubscribed(Context context, @Nullable String user, Multimap<String, NotificationChannel> subscribedRecipients) {
     if (user != null) {
       Collection<NotificationChannel> channels = subscribedRecipients.get(user);
       for (NotificationChannel channel : channels) {
index 971d3fe79768aca35633a5308df263743c87f929..69fca8eef51c28cf61a4516424993b5f3c3ace75 100644 (file)
@@ -66,7 +66,7 @@ public class DoNotFixNotificationDispatcher extends NotificationDispatcher {
     }
   }
 
-  private void notify(String author, Context context, Multimap<String, NotificationChannel> subscribedRecipients) {
+  private static void notify(String author, Context context, Multimap<String, NotificationChannel> subscribedRecipients) {
     for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
       String login = channelsByRecipients.getKey();
       // Do not notify the person that resolved the issue
index cc3a7f3fc220b96d949c24c46070bc75d6211a82..97cd80d2d9d089a6ef6f2095509951dd79950685 100644 (file)
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.EnumSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,7 +36,6 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.Duration;
 import org.sonar.api.utils.Durations;
 import org.sonar.api.utils.Paging;
-import org.sonar.server.issue.workflow.Transition;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.issue.ActionPlanDto;
 import org.sonar.db.issue.IssueChangeDto;
@@ -46,6 +46,7 @@ import org.sonar.db.rule.RuleDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.markdown.Markdown;
 import org.sonar.server.es.Facets;
+import org.sonar.server.issue.workflow.Transition;
 import org.sonar.server.ws.WsResponseCommonFormat;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Issues;
@@ -64,7 +65,7 @@ public class SearchResponseFormat {
     this.languages = languages;
   }
 
-  public Issues.SearchWsResponse formatSearch(Set<SearchAdditionalField> fields, SearchResponseData data,
+  public Issues.SearchWsResponse formatSearch(EnumSet<SearchAdditionalField> fields, SearchResponseData data,
     Paging paging, @Nullable Facets facets) {
     Issues.SearchWsResponse.Builder response = Issues.SearchWsResponse.newBuilder();
 
@@ -123,7 +124,7 @@ public class SearchResponseFormat {
     response.setPaging(commonFormat.formatPaging(paging));
   }
 
-  private List<Issues.Issue> formatIssues(Set<SearchAdditionalField> fields, SearchResponseData data) {
+  private List<Issues.Issue> formatIssues(EnumSet<SearchAdditionalField> fields, SearchResponseData data) {
     List<Issues.Issue> result = new ArrayList<>();
     Issues.Issue.Builder issueBuilder = Issues.Issue.newBuilder();
     for (IssueDto dto : data.getIssues()) {
index 5ca140ba8f6df5be24c4e2b95764bf2ede0d9a27..301214454fb778827cde7db27f795ace27ac1cf9 100644 (file)
@@ -104,7 +104,7 @@ public class WebServicesWs implements WebService {
       .setExampleValue("search");
   }
 
-  private void handleResponseExample(Action action, Response response) throws IOException {
+  private static void handleResponseExample(Action action, Response response) throws IOException {
     if (action.responseExample() != null) {
       response
         .newJsonWriter()
@@ -189,7 +189,7 @@ public class WebServicesWs implements WebService {
     }
   }
 
-  private void writeParam(JsonWriter writer, Param param) {
+  private static void writeParam(JsonWriter writer, Param param) {
     writer.beginObject();
     writer.prop("key", param.key());
     writer.prop("description", param.description());
index 82d94305d86a41787c36c10f724d14b2794612f0..19c28a622619c41dc5a08835e761aab3837a4fcc 100644 (file)
@@ -83,7 +83,7 @@ public class WidgetPropertyDao implements Dao {
     });
   }
 
-  private WidgetPropertyMapper mapper(DbSession session) {
+  private static WidgetPropertyMapper mapper(DbSession session) {
     return session.getMapper(WidgetPropertyMapper.class);
   }
 }
index cb9c14a51d85982fab2965f728dec88790e2e0f6..cd593b8b8b22b1927bc47d3d17ae123dd50a7eae 100644 (file)
@@ -117,7 +117,7 @@ public class PermissionTemplateDao implements Dao {
     return countGroups(session, query, templateId, null);
   }
 
-  private int countGroups(DbSession session, PermissionQuery query, long templateId, @Nullable String groupName) {
+  private static int countGroups(DbSession session, PermissionQuery query, long templateId, @Nullable String groupName) {
     Map<String, Object> parameters = groupsParameters(query, templateId);
     if (groupName != null) {
       parameters.put("groupName", groupName.toUpperCase());
index 2778afe56e93ff6006dd9b8abbc98f51f1f7f291..7f021639917331600fa45252f642242cc396274f 100644 (file)
@@ -171,7 +171,7 @@ public class Checks<C> {
     throw new IllegalStateException(String.format("Fail to instantiate class %s for rule %s", checkClassOrInstance, activeRule.ruleKey()), e);
   }
 
-  private void configureFields(ActiveRule activeRule, Object check) {
+  private static void configureFields(ActiveRule activeRule, Object check) {
     for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
       Field field = getField(check, param.getKey());
       if (field == null) {
index 0bd6997a7dd02f60b6b3fac051eb001a8d5ea6ca..be86b62992e9bd8dfd647620067247b7d55a9d15 100644 (file)
@@ -89,7 +89,7 @@ public final class AnnotationCheckFactory extends CheckFactory {
     }
   }
 
-  private void configureFields(ActiveRule activeRule, Object check) {
+  private static void configureFields(ActiveRule activeRule, Object check) {
     for (ActiveRuleParam param : activeRule.getActiveRuleParams()) {
       Field field = getField(check, param.getKey());
       if (field == null) {
index 404da38046e72fd96bb9784db068278c23f8ff73..fd0df622783d578362ed7f6afdd42820a60fca6f 100644 (file)
@@ -64,7 +64,7 @@ public final class AnnotationRuleParser {
     return null;
   }
 
-  private Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) {
+  private static Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) {
     String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName());
     String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null);
     String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null);