]> source.dussan.org Git - sonarqube.git/commitdiff
Fix code quality issues
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 23 Sep 2021 16:16:04 +0000 (11:16 -0500)
committersonartech <sonartech@sonarsource.com>
Fri, 24 Sep 2021 20:03:10 +0000 (20:03 +0000)
54 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolver.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/RegisterQualityProfileStatusStepTest.java
server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleMetadataDto.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilder.java
server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java
server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java
server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImpl.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/ResetPasswordFilterTest.java
server/sonar-webserver-core/src/main/java/org/sonar/server/platform/AbstractSystemInfoWriter.java
server/sonar-webserver-core/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectsTextSearchQueryFactory.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/InfoAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/AbstractChangeTagsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/DecorationDataHolder.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/HtmlTextDecorator.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
server/sonar-webserver/src/main/java/org/sonar/server/platform/web/PlatformServletContextListener.java
sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java [deleted file]
sonar-core/src/main/java/org/sonar/core/issue/FieldDiffs.java
sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
sonar-duplications/src/main/java/org/sonar/duplications/java/JavaTokenProducer.java
sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java

index bafc40cf4ef9e5dc3d4825602656a27ce4c405f6..b3386eca505eb8fecb5727e97ce88d5c27f52329 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.ce.task.projectanalysis.issue;
 
-import com.google.common.collect.ImmutableList;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Collection;
index f40b03d38fff14e68d69d579e44a0013e48bbc07..c2a2ad9f0634be7dd8a8f5d347f7bba8e19b72ca 100644 (file)
@@ -49,19 +49,19 @@ public class UpdateConflictResolver {
     resolveStatus(dbIssue, issue);
   }
 
-  private void resolveStatus(IssueDto dbIssue, DefaultIssue issue) {
+  private static void resolveStatus(IssueDto dbIssue, DefaultIssue issue) {
     issue.setStatus(dbIssue.getStatus());
   }
 
-  private void resolveResolution(IssueDto dbIssue, DefaultIssue issue) {
+  private static void resolveResolution(IssueDto dbIssue, DefaultIssue issue) {
     issue.setResolution(dbIssue.getResolution());
   }
 
-  private void resolveEffortToFix(IssueDto dbIssue, DefaultIssue issue) {
+  private static void resolveEffortToFix(IssueDto dbIssue, DefaultIssue issue) {
     issue.setGap(dbIssue.getGap());
   }
 
-  private void resolveSeverity(IssueDto dbIssue, DefaultIssue issue) {
+  private static void resolveSeverity(IssueDto dbIssue, DefaultIssue issue) {
     if (dbIssue.isManualSeverity()) {
       issue.setManualSeverity(true);
       issue.setSeverity(dbIssue.getSeverity());
@@ -69,7 +69,7 @@ public class UpdateConflictResolver {
     // else keep severity as declared in quality profile
   }
 
-  private void resolveAssignee(IssueDto dbIssue, DefaultIssue issue) {
+  private static void resolveAssignee(IssueDto dbIssue, DefaultIssue issue) {
     issue.setAssigneeUuid(dbIssue.getAssigneeUuid());
   }
 }
index 505e53851b3a1ca411230e47253df2af00a137ce..921fc7ea48a0b5bab6ce280d92dd2afa26158e94 100644 (file)
@@ -108,8 +108,8 @@ public class CommentMeasuresStep implements ComputationStep {
           double nclocs = nclocsOpt.get().getIntValue();
           double comments = commentsOpt.get();
           double divisor = nclocs + comments;
-          if (divisor > 0d) {
-            double value = 100d * (comments / divisor);
+          if (divisor > 0D) {
+            double value = 100D * (comments / divisor);
             return Optional.of(Measure.newMeasureBuilder().create(value, context.getMetric().getDecimalScale()));
           }
         }
@@ -153,9 +153,9 @@ public class CommentMeasuresStep implements ComputationStep {
         && counter.getPublicUndocumentedApiValue().isPresent()) {
         double publicApis = counter.getPublicApiValue().get();
         double publicUndocumentedApis = counter.getPublicUndocumentedApiValue().get();
-        if (publicApis > 0d) {
+        if (publicApis > 0D) {
           double documentedAPI = publicApis - publicUndocumentedApis;
-          double value = 100d * (documentedAPI / publicApis);
+          double value = 100D * (documentedAPI / publicApis);
           return Optional.of(Measure.newMeasureBuilder().create(value, context.getMetric().getDecimalScale()));
         }
       }
index 6a33321b52b6cfb4847dedf81bc43493103fe1a7..8b49a05d8295841843bf52b3cd049a15a0c39e2c 100644 (file)
@@ -215,8 +215,8 @@ public class NewSizeMeasuresStep implements ComputationStep {
       if (newLines.isSet() && newDuplicatedLines.isSet()) {
         int newLinesVariations = newLines.getValue();
         int newDuplicatedLinesVariations = newDuplicatedLines.getValue();
-        if (newLinesVariations > 0d) {
-          double density = Math.min(100d, 100d * newDuplicatedLinesVariations / newLinesVariations);
+        if (newLinesVariations > 0D) {
+          double density = Math.min(100D, 100D * newDuplicatedLinesVariations / newLinesVariations);
           return Optional.of(Measure.newMeasureBuilder().setVariation(density).createNoValue());
         }
       }
index eb1d1bae8934c07be086809c15b6bf3a2f1ef1ed..1dc926c495b69c5cd5c13a8a772e662701442aeb 100644 (file)
@@ -118,8 +118,8 @@ public class UnitTestMeasuresStep implements ComputationStep {
         int tests = counter.testsCounter.getValue().get();
         int errors = counter.testsErrorsCounter.getValue().get();
         int failures = counter.testsFailuresCounter.getValue().get();
-        double density = (errors + failures) * 100d / tests;
-        return Optional.of(Measure.newMeasureBuilder().create(100d - density, decimalScale));
+        double density = (errors + failures) * 100D / tests;
+        return Optional.of(Measure.newMeasureBuilder().create(100D - density, decimalScale));
       }
       return Optional.empty();
     }
index c55beae60e7fa385be2f35f2ecf4f0c022f4938b..d43e8caaccac00aa898686d3f9f2e4bce31fe8fc 100644 (file)
@@ -107,7 +107,7 @@ public class RegisterQualityProfileStatusStepTest {
 
     underTest.execute(new TestComputationStepContext());
 
-    verify(qProfileStatusRepository).register(eq(qp.getQpKey()), eq(REMOVED));
+    verify(qProfileStatusRepository).register(qp.getQpKey(), REMOVED);
     verifyNoMoreInteractions(qProfileStatusRepository);
   }
 
@@ -120,8 +120,8 @@ public class RegisterQualityProfileStatusStepTest {
     mockRawQProfiles(ImmutableList.of(qp1, qp2));
     underTest.execute(new TestComputationStepContext());
 
-    verify(qProfileStatusRepository).register(eq(qp1.getQpKey()), eq(UNCHANGED));
-    verify(qProfileStatusRepository).register(eq(qp2.getQpKey()), eq(ADDED));
+    verify(qProfileStatusRepository).register(qp1.getQpKey(), UNCHANGED);
+    verify(qProfileStatusRepository).register(qp2.getQpKey(), ADDED);
     verifyNoMoreInteractions(qProfileStatusRepository);
   }
 
@@ -134,7 +134,7 @@ public class RegisterQualityProfileStatusStepTest {
     mockRawQProfiles(ImmutableList.of(qp2));
     underTest.execute(new TestComputationStepContext());
 
-    verify(qProfileStatusRepository).register(eq(qp2.getQpKey()), eq(UPDATED));
+    verify(qProfileStatusRepository).register(qp2.getQpKey(), UPDATED);
     verifyNoMoreInteractions(qProfileStatusRepository);
   }
 
@@ -146,7 +146,7 @@ public class RegisterQualityProfileStatusStepTest {
     mockRawQProfiles(ImmutableList.of(qp1));
     underTest.execute(new TestComputationStepContext());
 
-    verify(qProfileStatusRepository).register(eq(qp1.getQpKey()), eq(UNCHANGED));
+    verify(qProfileStatusRepository).register(qp1.getQpKey(), UNCHANGED);
     verifyNoMoreInteractions(qProfileStatusRepository);
   }
 
index d3ebb0fec999deca73502368688094f3c8623ea6..67d93e293475116ab8537ed9ed2359b6a2f6f080 100644 (file)
@@ -102,7 +102,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
     }
   }
 
-  private Optional<CeQueueDto> findPendingTask(String workerUuid, DbSession dbSession, CeQueueDao ceQueueDao, boolean excludeIndexationJob) {
+  private static Optional<CeQueueDto> findPendingTask(String workerUuid, DbSession dbSession, CeQueueDao ceQueueDao, boolean excludeIndexationJob) {
     // try to find tasks including indexation job & excluding app/portfolio
     // and if no match, try the opposite
     // when excludeIndexationJob is false, search first excluding indexation jobs and including app/portfolio, then the opposite
index 19eab9689ea94f905a31031a04a25b02586968df..1a67185b9b67f6cbeab42b802d6bba40f84876b9 100644 (file)
@@ -41,10 +41,6 @@ public class RuleMetadataDto {
   private String remediationBaseEffort;
   private String tags;
 
-  public RuleMetadataDto() {
-    // nothing to do here
-  }
-
   /**
    * Name of on ad hoc rule.
    * When {@link RuleDefinitionDto#isAdHoc} is true, this field should always be set
@@ -71,6 +67,10 @@ public class RuleMetadataDto {
   private long createdAt;
   private long updatedAt;
 
+  public RuleMetadataDto() {
+    // nothing to do here
+  }
+
   public String getRuleUuid() {
     return ruleUuid;
   }
index 5b0315d8d1cbd6f32026c0f7807175f29ec63ee5..3ae34aad1be35ad42d7f21a64afeb635b27b870d 100644 (file)
@@ -115,16 +115,6 @@ public class AlterColumnsBuilder {
     return sqls;
   }
 
-  private void addColumns(StringBuilder sql, String updateKeyword, String typePrefix, boolean addNotNullableProperty) {
-    for (Iterator<ColumnDef> columnDefIterator = columnDefs.iterator(); columnDefIterator.hasNext();) {
-      sql.append(updateKeyword);
-      addColumn(sql, columnDefIterator.next(), typePrefix, addNotNullableProperty);
-      if (columnDefIterator.hasNext()) {
-        sql.append(", ");
-      }
-    }
-  }
-
   private void addColumn(StringBuilder sql, ColumnDef columnDef, String typePrefix, boolean addNotNullableProperty) {
     sql.append(columnDef.getName())
       .append(" ")
index b1cf76d4a3cdfe47c6415473ee40b85ef39ec864..bc183577bd41daeb43b386c0a671bbcc87e32fbb 100644 (file)
@@ -142,16 +142,4 @@ public class JdbcSettings implements Consumer<Props> {
       }
     }
   }
-
-  private static void checkRequiredParameter(String url, String val) {
-    if (!url.contains(val)) {
-      throw new MessageException(format("JDBC URL must have the property '%s'", val));
-    }
-  }
-
-  private void checkRecommendedParameter(String url, String val) {
-    if (!url.contains(val)) {
-      LoggerFactory.getLogger(getClass()).warn("JDBC URL is recommended to have the property '{}'", val);
-    }
-  }
 }
index 09439d9cbab58166945153f673bc2959aaf15838..817344f235b1e53b08729b4cf476f61dfa34e8d7 100644 (file)
@@ -23,11 +23,6 @@ package org.sonar.process.cluster.hz;
  * This class holds all object keys accessible via Hazelcast
  */
 public final class HazelcastObjects {
-
-  private HazelcastObjects() {
-    // Holder for clustered objects
-  }
-
   /**
    * The key of replicated map that hold all operational processes
    */
@@ -57,4 +52,8 @@ public final class HazelcastObjects {
    * THe key of the replicated map holding the health state information of all SQ nodes.
    */
   public static final String SQ_HEALTH_STATE = "sq_health_state";
+
+  private HazelcastObjects() {
+    // Holder for clustered objects
+  }
 }
index 9873b57e302581457ca9dd508f331f5c919e17b6..8a4cee79eb3cf0932399f58fc6d20f015251f203 100644 (file)
@@ -49,7 +49,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
     @Override
     public QueryBuilder getQuery(ComponentTextSearchQuery query) {
       return matchQuery(SORTABLE_ANALYZER.subField(query.getFieldName()), query.getQueryText())
-        .boost(2.5f);
+        .boost(2.5F);
     }
   },
   PREFIX(CHANGE_ORDER_OF_RESULTS) {
@@ -73,7 +73,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
       }
       List<String> lowerCaseTokens = tokens.stream().map(t -> t.toLowerCase(Locale.ENGLISH)).collect(MoreCollectors.toList());
       BoolQueryBuilder queryBuilder = prefixAndPartialQuery(lowerCaseTokens, query.getFieldName(), SEARCH_PREFIX_CASE_INSENSITIVE_ANALYZER)
-        .boost(2f);
+        .boost(2F);
       return Stream.of(queryBuilder);
     }
   },
@@ -84,7 +84,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
       if (tokens.isEmpty()) {
         return Stream.empty();
       }
-      BoolQueryBuilder queryBuilder = boolQuery().boost(0.5f);
+      BoolQueryBuilder queryBuilder = boolQuery().boost(0.5F);
       tokens.stream()
         .map(text -> tokenQuery(text, query.getFieldName(), SEARCH_GRAMS_ANALYZER))
         .forEach(queryBuilder::must);
@@ -95,7 +95,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
     @Override
     public QueryBuilder getQuery(ComponentTextSearchQuery query) {
       return matchQuery(SORTABLE_ANALYZER.subField(query.getFieldKey()), query.getQueryText())
-        .boost(50f);
+        .boost(50F);
     }
   },
   RECENTLY_BROWSED(CHANGE_ORDER_OF_RESULTS) {
@@ -105,7 +105,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
       if (recentlyBrowsedKeys.isEmpty()) {
         return Stream.empty();
       }
-      return Stream.of(termsQuery(query.getFieldKey(), recentlyBrowsedKeys).boost(100f));
+      return Stream.of(termsQuery(query.getFieldKey(), recentlyBrowsedKeys).boost(100F));
     }
   },
   FAVORITE(CHANGE_ORDER_OF_RESULTS) {
@@ -115,7 +115,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF
       if (favoriteKeys.isEmpty()) {
         return Stream.empty();
       }
-      return Stream.of(termsQuery(query.getFieldKey(), favoriteKeys).boost(1000f));
+      return Stream.of(termsQuery(query.getFieldKey(), favoriteKeys).boost(1000F));
     }
   };
 
index 73c7d7a0f808f99681d7b204c83570c444e74ea0..dd1c529d799910cff6a0567732c3d9954fcbc8ab 100644 (file)
@@ -211,28 +211,25 @@ public class RuleIndex {
 
     // Build RuleBased contextual query
     BoolQueryBuilder qb = boolQuery();
-    String queryString = query.getQueryText();
-
-    if (queryString != null && !queryString.isEmpty()) {
-      BoolQueryBuilder textQuery = boolQuery();
-      JavaTokenizer.split(queryString)
-        .stream().map(token -> boolQuery().should(
-        matchQuery(
-          SEARCH_GRAMS_ANALYZER.subField(FIELD_RULE_NAME),
-          StringUtils.left(token, DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH)).boost(20f))
-        .should(
-          matchPhraseQuery(
-            ENGLISH_HTML_ANALYZER.subField(FIELD_RULE_HTML_DESCRIPTION),
-            token).boost(3f)))
-        .forEach(textQuery::must);
-      qb.should(textQuery.boost(20f));
-    }
+
+    BoolQueryBuilder textQuery = boolQuery();
+    JavaTokenizer.split(queryText)
+      .stream().map(token -> boolQuery().should(
+      matchQuery(
+        SEARCH_GRAMS_ANALYZER.subField(FIELD_RULE_NAME),
+        StringUtils.left(token, DefaultIndexSettings.MAXIMUM_NGRAM_LENGTH)).boost(20f))
+      .should(
+        matchPhraseQuery(
+          ENGLISH_HTML_ANALYZER.subField(FIELD_RULE_HTML_DESCRIPTION),
+          token).boost(3F)))
+      .forEach(textQuery::must);
+    qb.should(textQuery.boost(20F));
 
     // Match and partial Match queries
     // Search by key uses the "sortable" sub-field as it requires to be case-insensitive (lower-case filtering)
-    qb.should(matchQuery(SORTABLE_ANALYZER.subField(FIELD_RULE_KEY), queryString).operator(Operator.AND).boost(30f));
-    qb.should(matchQuery(SORTABLE_ANALYZER.subField(FIELD_RULE_RULE_KEY), queryString).operator(Operator.AND).boost(15f));
-    qb.should(termQuery(FIELD_RULE_LANGUAGE, queryString, 3f));
+    qb.should(matchQuery(SORTABLE_ANALYZER.subField(FIELD_RULE_KEY), queryText).operator(Operator.AND).boost(30F));
+    qb.should(matchQuery(SORTABLE_ANALYZER.subField(FIELD_RULE_RULE_KEY), queryText).operator(Operator.AND).boost(15F));
+    qb.should(termQuery(FIELD_RULE_LANGUAGE, queryText, 3F));
     return qb;
   }
 
index e202dfa94dffb8315350d41dede4fa0e5a2518cd..7f3f8d34678d5361de17b14f958ac3587443a9fd 100644 (file)
@@ -238,7 +238,7 @@ public class PluginJarLoader {
     return list;
   }
 
-  private void failIfContainsIncompatiblePlugins(List<? extends PluginInfo> plugins) {
+  private static void failIfContainsIncompatiblePlugins(List<? extends PluginInfo> plugins) {
     List<String> incompatiblePlugins = plugins.stream()
       .filter(p -> FORBIDDEN_INCOMPATIBLE_PLUGINS.contains(p.getKey()))
       .map(p -> "'" + p.getKey() + "'")
index 207d2736f27dfbbf13405a7bd2edff5c0f760755..dba73b815250f434fcde8ca5679c7621f2baf3f5 100644 (file)
@@ -52,11 +52,6 @@ public class OAuth2AuthenticationParametersImpl implements OAuth2AuthenticationP
    */
   private static final String RETURN_TO_PARAMETER = "return_to";
 
-  /**
-   * This parameter is used to allow the update of login
-   */
-  private static final String ALLOW_LOGIN_UPDATE_PARAMETER = "allowUpdateLogin";
-
   private static final Type JSON_MAP_TYPE = new TypeToken<HashMap<String, String>>() {
   }.getType();
 
index 6c45615d3bfdf7b87cf616ad4b436e09dbc1d315..503b8be6149b3846f16bd183c9df2c53c320f138 100644 (file)
@@ -168,7 +168,7 @@ public class OAuth2CallbackFilterTest {
     assertThat(authenticationException.getSource()).isEqualTo(Source.oauth2(identityProvider));
     assertThat(authenticationException.getLogin()).isNull();
     assertThat(authenticationException.getPublicMessage()).isEqualTo("Email john@email.com is already used");
-    verify(oAuthRedirection).delete(eq(request), eq(response));
+    verify(oAuthRedirection).delete(request, response);
 
     verify(response).addCookie(cookieArgumentCaptor.capture());
     Cookie cookie = cookieArgumentCaptor.getValue();
@@ -190,7 +190,7 @@ public class OAuth2CallbackFilterTest {
     underTest.doFilter(request, response, chain);
 
     verify(response).sendRedirect("/sonarqube/sessions/unauthorized");
-    verify(oAuthRedirection).delete(eq(request), eq(response));
+    verify(oAuthRedirection).delete(request, response);
   }
 
   @Test
@@ -203,7 +203,7 @@ public class OAuth2CallbackFilterTest {
 
     verify(response).sendRedirect("/sessions/unauthorized");
     assertThat(logTester.logs(LoggerLevel.WARN)).containsExactlyInAnyOrder("Fail to callback authentication with 'failing'");
-    verify(oAuthRedirection).delete(eq(request), eq(response));
+    verify(oAuthRedirection).delete(request, response);
   }
 
   @Test
index 8a0dd6ac2b75b76b3b09654db78d2d5e083bb333..319b9a27bf4bfb4a759706c165b0596155dc62d2 100644 (file)
@@ -73,7 +73,7 @@ public class ResetPasswordFilterTest {
   public void redirect_if_reset_password_set() throws Exception {
     underTest.doFilter(request, response, chain);
 
-    verify(response).sendRedirect(eq("/account/reset_password"));
+    verify(response).sendRedirect("/account/reset_password");
   }
 
   @Test
@@ -82,7 +82,7 @@ public class ResetPasswordFilterTest {
 
     underTest.doFilter(request, response, chain);
 
-    verify(response).sendRedirect(eq("/sonarqube/account/reset_password"));
+    verify(response).sendRedirect("/sonarqube/account/reset_password");
   }
 
   @Test
@@ -92,7 +92,7 @@ public class ResetPasswordFilterTest {
 
     underTest.doFilter(request, response, chain);
 
-    verify(response).sendRedirect(eq("/sonarqube/account/reset_password"));
+    verify(response).sendRedirect("/sonarqube/account/reset_password");
   }
 
   @Test
index 95f556a3c348ffcb130f32053f324f592e4c80bb..aff00e45cf115176e447c6e48acbad3205ad72cd 100644 (file)
@@ -60,7 +60,7 @@ public abstract class AbstractSystemInfoWriter implements SystemInfoWriter {
     json.endObject();
   }
 
-  private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
+  private static void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
     switch (attribute.getValueCase()) {
       case BOOLEAN_VALUE:
         json.prop(attribute.getKey(), attribute.getBooleanValue());
index 8d33e4bd20cf3bb70bdbc3cb25c0d5002a989337..69e561a4a40f872241e3965d9bb1321e451842e1 100644 (file)
@@ -116,8 +116,8 @@ public class CommonRuleDefinitionsImpl implements CommonRuleDefinitions {
     rule
       .setName("Failed unit tests should be fixed")
       .addTags("bug")
-      .setHtmlDescription(
-        "Test failures or errors generally indicate that regressions have been introduced. Those tests should be handled as soon as possible to reduce the cost to fix the corresponding regressions.")
+      .setHtmlDescription("Test failures or errors generally indicate that regressions have been introduced. "
+        + "Those tests should be handled as soon as possible to reduce the cost to fix the corresponding regressions.")
       .setDebtRemediationFunction(rule.debtRemediationFunctions().linear("10min"))
       .setGapDescription("number of failed tests")
       .setSeverity(Severity.MAJOR);
index 1760041827b118482cb4a88b741581cb88fd7e27..4a37f07d28460e63280f8b54840bbacbb952dd4e 100644 (file)
@@ -124,7 +124,7 @@ public class RegisterMetrics implements Startable {
     return metricsToRegister;
   }
 
-  private void checkMetrics(Map<String, Metrics> metricsByRepository, Metrics metrics) {
+  private static void checkMetrics(Map<String, Metrics> metricsByRepository, Metrics metrics) {
     for (Metric metric : metrics.getMetrics()) {
       String metricKey = metric.getKey();
       if (CoreMetrics.getMetrics().contains(metric)) {
index 48082da3e9dc0c1c07223000bd826dea087571c4..ed80458dd0e9e801c5ddd76bd47088893d8399de 100644 (file)
@@ -737,13 +737,12 @@ public class IssueIndex {
     AggregationBuilder aggregation = aggregationHelper.buildTermTopAggregation(
       RESOLUTIONS.getName(), RESOLUTIONS.getTopAggregationDef(), RESOLUTIONS.getNumberOfTerms(),
       NO_EXTRA_FILTER,
-      t -> {
+      t ->
         // add aggregation of type "missing" to return count of unresolved issues in the facet
         t.subAggregation(
           addEffortAggregationIfNeeded(query, AggregationBuilders
             .missing(RESOLUTIONS.getName() + FACET_SUFFIX_MISSING)
-            .field(RESOLUTIONS.getFieldName())));
-      });
+            .field(RESOLUTIONS.getFieldName()))));
     esRequest.aggregation(aggregation);
   }
 
@@ -862,12 +861,11 @@ public class IssueIndex {
         ASSIGNED_TO_ME.getTopAggregationDef(),
         ASSIGNED_TO_ME.getNumberOfTerms(),
         NO_EXTRA_FILTER,
-        t -> {
+        t ->
           // add sub-aggregation to return issue count for current user
           aggregationHelper.getSubAggregationHelper()
             .buildSelectedItemsAggregation(ASSIGNED_TO_ME.getName(), ASSIGNED_TO_ME.getTopAggregationDef(), new String[] {uuid})
-            .ifPresent(t::subAggregation);
-        });
+            .ifPresent(t::subAggregation));
       esRequest.aggregation(aggregation);
     }
   }
index d8884fb0de60f7db3aeb6d10396da9ec555ee811..be9f6f529faca150ec1e134dbb846309e7b150d6 100644 (file)
@@ -61,14 +61,14 @@ class ProjectsTextSearchQueryFactory {
       @Override
       QueryBuilder getQuery(String queryText) {
         return matchQuery(SORTABLE_ANALYZER.subField(FIELD_NAME), queryText)
-          .boost(2.5f);
+          .boost(2.5F);
       }
     },
     PREFIX {
       @Override
       QueryBuilder getQuery(String queryText) {
         return prefixAndPartialQuery(queryText, FIELD_NAME, FIELD_NAME)
-          .boost(2f);
+          .boost(2F);
       }
     },
     PREFIX_IGNORE_CASE {
@@ -76,7 +76,7 @@ class ProjectsTextSearchQueryFactory {
       QueryBuilder getQuery(String queryText) {
         String lowerCaseQueryText = queryText.toLowerCase(Locale.ENGLISH);
         return prefixAndPartialQuery(lowerCaseQueryText, SORTABLE_ANALYZER.subField(FIELD_NAME), FIELD_NAME)
-          .boost(3f);
+          .boost(3F);
       }
     },
     PARTIAL {
@@ -87,7 +87,7 @@ class ProjectsTextSearchQueryFactory {
           .map(text -> partialTermQuery(text, FIELD_NAME))
           .forEach(queryBuilder::must);
         return queryBuilder
-          .boost(0.5f);
+          .boost(0.5F);
       }
     },
     KEY {
@@ -95,7 +95,7 @@ class ProjectsTextSearchQueryFactory {
       QueryBuilder getQuery(String queryText) {
         return wildcardQuery(SORTABLE_ANALYZER.subField(FIELD_KEY), "*" + queryText + "*")
           .caseInsensitive(true)
-          .boost(50f);
+          .boost(50F);
       }
     };
 
index f9a295db8030de7df1ecb863a7ebcad39720a436..99bd317ed4d8e31cf9891b23284e986972894d40 100644 (file)
@@ -57,9 +57,6 @@ import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
 public class SearchBitbucketServerReposAction implements AlmIntegrationsWsAction {
-
-  private static final Logger LOG = Loggers.get(SearchBitbucketServerReposAction.class);
-
   private static final String PARAM_ALM_SETTING = "almSetting";
   private static final String PARAM_REPO_NAME = "repositoryName";
   private static final String PARAM_PROJECT_NAME = "projectName";
index 5b446821cc1487d9eef9c15069064c5e3b67eaf4..95dd958a4d7c8dacf28c820c43b35659258888a5 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.badge.ws;
 
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.WebService;
-import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
 import org.sonar.db.project.ProjectDto;
@@ -40,12 +39,10 @@ public class ProjectBadgesSupport {
   private static final String PARAM_BRANCH = "branch";
 
   private final UserSession userSession;
-  private final DbClient dbClient;
   private final ComponentFinder componentFinder;
 
-  public ProjectBadgesSupport(UserSession userSession, DbClient dbClient, ComponentFinder componentFinder) {
+  public ProjectBadgesSupport(UserSession userSession, ComponentFinder componentFinder) {
     this.userSession = userSession;
-    this.dbClient = dbClient;
     this.componentFinder = componentFinder;
   }
 
index d5036078e1d3a639eb683835c3d3ba372a5c7f1c..3ffa358b4bc28c2c731b538e3e349b797cd0d849 100644 (file)
@@ -112,7 +112,7 @@ public class ProjectDataLoader {
     }
   }
 
-  private void checkPermission(boolean hasScanPerm) {
+  private static void checkPermission(boolean hasScanPerm) {
     if (!hasScanPerm) {
       throw new ForbiddenException("You're not authorized to push analysis results to the SonarQube server. " +
         "Please contact your SonarQube administrator.");
index ce0c5092b0fc72ba3c40a1b79bbe41ec19bee5ae..326b7414cfa0bdbb0e19ffbc69003672e4c34673 100644 (file)
@@ -65,7 +65,7 @@ public class InfoAction implements CeWsAction {
     WsUtils.writeProtobuf(builder.build(), request, response);
   }
 
-  private Ce.WorkersPauseStatus convert(CeQueue.WorkersPauseStatus status) {
+  private static Ce.WorkersPauseStatus convert(CeQueue.WorkersPauseStatus status) {
     switch (status) {
       case PAUSING:
         return Ce.WorkersPauseStatus.PAUSING;
index d05d9d1eaca8a428ba8c53a472f9e6c966282779..f56a6a6a370624c5cf6c367c8abe10e4b68786e2 100644 (file)
@@ -46,7 +46,6 @@ import org.sonar.server.issue.TextRangeResponseFormatter;
 import org.sonar.server.issue.ws.UserResponseFormatter;
 import org.sonar.server.rule.HotspotRuleDescription;
 import org.sonar.server.security.SecurityStandards;
-import org.sonar.server.text.MacroInterpreter;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Hotspots;
 import org.sonarqube.ws.Hotspots.ShowWsResponse;
@@ -71,18 +70,15 @@ public class ShowAction implements HotspotsWsAction {
   private final TextRangeResponseFormatter textRangeFormatter;
   private final UserResponseFormatter userFormatter;
   private final IssueChangeWSSupport issueChangeSupport;
-  private final MacroInterpreter macroInterpreter;
 
-  public ShowAction(DbClient dbClient, HotspotWsSupport hotspotWsSupport,
-    HotspotWsResponseFormatter responseFormatter, TextRangeResponseFormatter textRangeFormatter,
-    UserResponseFormatter userFormatter, IssueChangeWSSupport issueChangeSupport, MacroInterpreter macroInterpreter) {
+  public ShowAction(DbClient dbClient, HotspotWsSupport hotspotWsSupport, HotspotWsResponseFormatter responseFormatter, TextRangeResponseFormatter textRangeFormatter,
+    UserResponseFormatter userFormatter, IssueChangeWSSupport issueChangeSupport) {
     this.dbClient = dbClient;
     this.hotspotWsSupport = hotspotWsSupport;
     this.responseFormatter = responseFormatter;
     this.textRangeFormatter = textRangeFormatter;
     this.userFormatter = userFormatter;
     this.issueChangeSupport = issueChangeSupport;
-    this.macroInterpreter = macroInterpreter;
   }
 
   @Override
@@ -158,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();
 
index 99cc063b64d8f03feb937dbf8071a24bc1f57edd..357a9bdb6a33c8644df0486744833a5ab65afafd 100644 (file)
@@ -65,7 +65,7 @@ public abstract class AbstractChangeTagsAction extends Action {
     return false;
   }
 
-  private Set<String> parseTags(Map<String, Object> properties) {
+  private static Set<String> parseTags(Map<String, Object> properties) {
     Set<String> result = new HashSet<>();
     String tagsString = (String) properties.get(TAGS_PARAMETER);
     if (!Strings.isNullOrEmpty(tagsString)) {
index 383de3a2800c9a210893b2c24485cda3f82d5f72..cbb16109ba254d0bc2713154523d1d16418d2aa9 100644 (file)
@@ -215,7 +215,7 @@ public class ComponentAction implements MeasuresWsAction {
     }
   }
 
-  private boolean isPR(@Nullable String pullRequest) {
+  private static boolean isPR(@Nullable String pullRequest) {
     return pullRequest != null;
   }
 
index e56d72b6770b9bb8ff64eca7cd4cde60cdca0619..cfd5dd1150cf13424693d29458598ea9abb3fa83 100644 (file)
@@ -158,7 +158,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   private final ResourceTypes resourceTypes;
 
   public ComponentTreeAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, I18n i18n,
-                             ResourceTypes resourceTypes) {
+    ResourceTypes resourceTypes) {
     this.dbClient = dbClient;
     this.componentFinder = componentFinder;
     this.userSession = userSession;
@@ -369,7 +369,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static Measures.Component.Builder toWsComponent(ComponentDto component, Map<MetricDto, ComponentTreeData.Measure> measures,
-                                                          Map<String, ComponentDto> referenceComponentsByUuid) {
+    Map<String, ComponentDto> referenceComponentsByUuid) {
     Measures.Component.Builder wsComponent = componentDtoToWsComponent(component);
     ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid());
     if (referenceComponent != null) {
@@ -447,7 +447,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
     }
   }
 
-  private boolean isPR(@Nullable String pullRequest) {
+  private static boolean isPR(@Nullable String pullRequest) {
     return pullRequest != null;
   }
 
@@ -502,7 +502,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private Table<String, MetricDto, ComponentTreeData.Measure> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent,
-                                                                                                     ComponentTreeQuery componentTreeQuery, List<ComponentDto> components, List<MetricDto> metrics) {
+    ComponentTreeQuery componentTreeQuery, List<ComponentDto> components, List<MetricDto> metrics) {
 
     Map<String, MetricDto> metricsByUuid = Maps.uniqueIndex(metrics, MetricDto::getUuid);
     MeasureTreeQuery measureQuery = MeasureTreeQuery.builder()
@@ -534,7 +534,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
    * </ul>
    */
   private static void addBestValuesToMeasures(Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<ComponentDto> components,
-                                              List<MetricDto> metrics) {
+    List<MetricDto> metrics) {
     List<MetricDtoWithBestValue> metricDtosWithBestValueMeasure = metrics.stream()
       .filter(MetricDtoFunctions.isOptimizedForBestValue())
       .map(new MetricDtoToMetricDtoWithBestValue())
@@ -555,7 +555,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static List<ComponentDto> filterComponents(List<ComponentDto> components,
-                                                     Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<MetricDto> metrics, ComponentTreeRequest wsRequest) {
+    Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric, List<MetricDto> metrics, ComponentTreeRequest wsRequest) {
     if (!componentWithMeasuresOnly(wsRequest)) {
       return components;
     }
@@ -575,7 +575,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
   }
 
   private static List<ComponentDto> sortComponents(List<ComponentDto> components, ComponentTreeRequest wsRequest, List<MetricDto> metrics,
-                                                   Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) {
+    Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) {
     return ComponentTreeSort.sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric);
   }
 
index b51fd838d6fb1376b951fdd4bc687f434b99a025..54b2c6e89a17c3a245755176dd8eb929b5f92aa2 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.metric.MetricDto;
 
 public class MeasureValueFormatter {
-  private static final double DELTA = 0.000001d;
+  private static final double DELTA = 0.000001D;
 
   private MeasureValueFormatter() {
     // static methods
@@ -97,7 +97,7 @@ public class MeasureValueFormatter {
   }
 
   private static String formatBoolean(double value) {
-    return Math.abs(value - 1.0d) < DELTA ? "true" : "false";
+    return Math.abs(value - 1.0D) < DELTA ? "true" : "false";
   }
 
   private static String formatInteger(double value) {
index 56ed04e44f3d93da4782d09370a6bba2a086d9e4..f0d69ff263a7fd6c7e8914fac8b6732c17a0e91f 100644 (file)
@@ -112,7 +112,7 @@ class DecorationDataHolder {
     }
   }
 
-  private void insertAndPreserveOrder(OpeningHtmlTag newEntry, List<OpeningHtmlTag> openingHtmlTags) {
+  private static void insertAndPreserveOrder(OpeningHtmlTag newEntry, List<OpeningHtmlTag> openingHtmlTags) {
     int insertionIndex = 0;
     Iterator<OpeningHtmlTag> tagIterator = openingHtmlTags.iterator();
     while (tagIterator.hasNext() && tagIterator.next().getStartOffset() <= newEntry.getStartOffset()) {
@@ -121,7 +121,7 @@ class DecorationDataHolder {
     openingHtmlTags.add(insertionIndex, newEntry);
   }
 
-  private void insertAndPreserveOrder(int newOffset, List<Integer> orderedOffsets) {
+  private static void insertAndPreserveOrder(int newOffset, List<Integer> orderedOffsets) {
     int insertionIndex = 0;
     Iterator<Integer> entriesIterator = orderedOffsets.iterator();
     while (entriesIterator.hasNext() && entriesIterator.next() <= newOffset) {
index 8b9eb59b1a2b2d77dc4903da73ebf1ec3a9e7d6e..1449e98f7792e5224382a8f725ad3e3106025f5d 100644 (file)
@@ -129,7 +129,7 @@ class HtmlTextDecorator {
     return to != null && to < currentLine;
   }
 
-  private char[] normalize(char currentChar) {
+  private static char[] normalize(char currentChar) {
     char[] normalizedChars;
     if (currentChar == HTML_OPENING) {
       normalizedChars = ENCODED_HTML_OPENING.toCharArray();
@@ -143,11 +143,11 @@ class HtmlTextDecorator {
     return normalizedChars;
   }
 
-  private boolean shouldAppendCharToHtmlOutput(CharactersReader charsReader) {
+  private static boolean shouldAppendCharToHtmlOutput(CharactersReader charsReader) {
     return charsReader.getCurrentValue() != CR_END_OF_LINE && charsReader.getCurrentValue() != LF_END_OF_LINE;
   }
 
-  private int getNumberOfTagsToClose(int currentIndex, DecorationDataHolder dataHolder) {
+  private static int getNumberOfTagsToClose(int currentIndex, DecorationDataHolder dataHolder) {
     int numberOfTagsToClose = 0;
 
     while (currentIndex == dataHolder.getCurrentClosingTagOffset()) {
@@ -157,7 +157,7 @@ class HtmlTextDecorator {
     return numberOfTagsToClose;
   }
 
-  private Collection<String> getTagsToOpen(int currentIndex, DecorationDataHolder dataHolder) {
+  private static Collection<String> getTagsToOpen(int currentIndex, DecorationDataHolder dataHolder) {
     Collection<String> tagsToOpen = newArrayList();
     while (dataHolder.getCurrentOpeningTagEntry() != null && currentIndex == dataHolder.getCurrentOpeningTagEntry().getStartOffset()) {
       tagsToOpen.add(dataHolder.getCurrentOpeningTagEntry().getCssClass());
@@ -166,24 +166,24 @@ class HtmlTextDecorator {
     return tagsToOpen;
   }
 
-  private boolean shouldClosePendingTags(CharactersReader charactersReader) {
+  private static boolean shouldClosePendingTags(CharactersReader charactersReader) {
     return charactersReader.getCurrentValue() == CR_END_OF_LINE
       || (charactersReader.getCurrentValue() == LF_END_OF_LINE && charactersReader.getPreviousValue() != CR_END_OF_LINE)
       || (charactersReader.getCurrentValue() == CharactersReader.END_OF_STREAM && charactersReader.getPreviousValue() != LF_END_OF_LINE);
   }
 
-  private boolean shouldReopenPendingTags(CharactersReader charactersReader) {
+  private static boolean shouldReopenPendingTags(CharactersReader charactersReader) {
     return (charactersReader.getPreviousValue() == LF_END_OF_LINE && charactersReader.getCurrentValue() != LF_END_OF_LINE)
       || (charactersReader.getPreviousValue() == CR_END_OF_LINE && charactersReader.getCurrentValue() != CR_END_OF_LINE
         && charactersReader.getCurrentValue() != LF_END_OF_LINE);
   }
 
-  private boolean shouldStartNewLine(CharactersReader charactersReader) {
+  private static boolean shouldStartNewLine(CharactersReader charactersReader) {
     return charactersReader.getPreviousValue() == LF_END_OF_LINE
       || (charactersReader.getPreviousValue() == CR_END_OF_LINE && charactersReader.getCurrentValue() != LF_END_OF_LINE);
   }
 
-  private void closeCompletedTags(CharactersReader charactersReader, int numberOfTagsToClose,
+  private static void closeCompletedTags(CharactersReader charactersReader, int numberOfTagsToClose,
     StringBuilder decoratedText) {
     for (int i = 0; i < numberOfTagsToClose; i++) {
       injectClosingHtml(decoratedText);
@@ -191,7 +191,7 @@ class HtmlTextDecorator {
     }
   }
 
-  private void openNewTags(CharactersReader charactersReader, Collection<String> tagsToOpen,
+  private static void openNewTags(CharactersReader charactersReader, Collection<String> tagsToOpen,
     StringBuilder decoratedText) {
     for (String tagToOpen : tagsToOpen) {
       injectOpeningHtmlForRule(tagToOpen, decoratedText);
@@ -199,23 +199,23 @@ class HtmlTextDecorator {
     }
   }
 
-  private void closeCurrentSyntaxTags(CharactersReader charactersReader, StringBuilder decoratedText) {
+  private static void closeCurrentSyntaxTags(CharactersReader charactersReader, StringBuilder decoratedText) {
     for (int i = 0; i < charactersReader.getOpenTags().size(); i++) {
       injectClosingHtml(decoratedText);
     }
   }
 
-  private void reopenCurrentSyntaxTags(CharactersReader charactersReader, StringBuilder decoratedText) {
+  private static void reopenCurrentSyntaxTags(CharactersReader charactersReader, StringBuilder decoratedText) {
     for (String tags : charactersReader.getOpenTags()) {
       injectOpeningHtmlForRule(tags, decoratedText);
     }
   }
 
-  private void injectOpeningHtmlForRule(String textType, StringBuilder decoratedText) {
+  private static void injectOpeningHtmlForRule(String textType, StringBuilder decoratedText) {
     decoratedText.append("<span class=\"").append(textType).append("\">");
   }
 
-  private void injectClosingHtml(StringBuilder decoratedText) {
+  private static void injectClosingHtml(StringBuilder decoratedText) {
     decoratedText.append("</span>");
   }
 }
index 458cf2db55a521195c94ff28a8b11b8fb84bf00f..19bb7c6b2b072141083a9bbc1a5a871958ba0e16 100644 (file)
@@ -84,7 +84,7 @@ public class MeasureActionTest {
   private WsActionTester ws = new WsActionTester(
     new MeasureAction(
       db.getDbClient(),
-      new ProjectBadgesSupport(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null)),
+      new ProjectBadgesSupport(userSession, new ComponentFinder(db.getDbClient(), null)),
       new SvgGenerator(mapSettings.asConfig())));
 
   @Test
index 1c0a44ac9990b950a7fd3f478978102cb550da30..b5b66edd5dc3d3ca581dc4cac6ced792dd1f5115 100644 (file)
@@ -64,7 +64,7 @@ public class QualityGateActionTest {
 
   private WsActionTester ws = new WsActionTester(
     new QualityGateAction(db.getDbClient(),
-      new ProjectBadgesSupport(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null)),
+      new ProjectBadgesSupport(userSession, new ComponentFinder(db.getDbClient(), null)),
       new SvgGenerator(mapSettings.asConfig())));
 
   @Test
index dfc9a5cfaa59912f5c360cbd7d6e593b963ca225..7c4189fc49789f24abf9a41e9e36ebd7fa049798 100644 (file)
@@ -35,7 +35,6 @@ import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
 import org.assertj.core.groups.Tuple;
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -70,7 +69,6 @@ import org.sonar.server.issue.ws.UserResponseFormatter;
 import org.sonar.server.security.SecurityStandards;
 import org.sonar.server.security.SecurityStandards.SQCategory;
 import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.text.MacroInterpreter;
 import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.WsActionTester;
 import org.sonarqube.ws.Common;
@@ -84,13 +82,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anySet;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
@@ -99,7 +93,6 @@ import static org.sonar.db.rule.RuleDto.Format.MARKDOWN;
 @RunWith(DataProviderRunner.class)
 public class ShowActionTest {
   private static final Random RANDOM = new Random();
-  private static final String INTERPRETED = "interpreted";
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -109,21 +102,15 @@ public class ShowActionTest {
   public UserSessionRule userSessionRule = UserSessionRule.standalone();
 
   private final DbClient dbClient = dbTester.getDbClient();
-  private final MacroInterpreter macroInterpreter = mock(MacroInterpreter.class);
   private final AvatarResolver avatarResolver = new AvatarResolverImpl();
   private final HotspotWsResponseFormatter responseFormatter = new HotspotWsResponseFormatter();
   private final IssueChangeWSSupport issueChangeSupport = Mockito.mock(IssueChangeWSSupport.class);
   private final HotspotWsSupport hotspotWsSupport = new HotspotWsSupport(dbClient, userSessionRule, System2.INSTANCE);
   private final UserResponseFormatter userFormatter = new UserResponseFormatter(new AvatarResolverImpl());
   private final TextRangeResponseFormatter textRangeFormatter = new TextRangeResponseFormatter();
-  private final ShowAction underTest = new ShowAction(dbClient, hotspotWsSupport, responseFormatter, textRangeFormatter, userFormatter, issueChangeSupport, macroInterpreter);
+  private final ShowAction underTest = new ShowAction(dbClient, hotspotWsSupport, responseFormatter, textRangeFormatter, userFormatter, issueChangeSupport);
   private final WsActionTester actionTester = new WsActionTester(underTest);
 
-  @Before
-  public void before() {
-    doReturn(INTERPRETED).when(macroInterpreter).interpret(anyString());
-  }
-
   @Test
   public void ws_is_public() {
     assertThat(actionTester.getDef().isInternal()).isFalse();
@@ -419,8 +406,6 @@ public class ShowActionTest {
       .executeProtobuf(Hotspots.ShowWsResponse.class);
 
     assertThat(response.getRule().getRiskDescription()).isNullOrEmpty();
-
-    verifyNoInteractions(macroInterpreter);
   }
 
   @Test
index cfe7606bbf29e63172b5c198a26c2af4169ef3f9..e5ba5fff40c1e330e7d80352ba91edc6f0e9c9f7 100644 (file)
@@ -53,7 +53,7 @@ public final class PlatformServletContextListener implements ServletContextListe
     }
   }
 
-  private void stopQuietly() {
+  private static void stopQuietly() {
     try {
       PlatformImpl.getInstance().doStop();
     } catch (Exception e) {
diff --git a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java b/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java
deleted file mode 100644 (file)
index fa6809c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.extension;
-
-public final class ExtensionProviderSupport {
-  private ExtensionProviderSupport() {
-    // prevents implementation
-  }
-
-  private static boolean isType(Object extension, Class extensionClass) {
-    Class clazz = extension instanceof Class ? (Class) extension : extension.getClass();
-    return extensionClass.isAssignableFrom(clazz);
-  }
-}
index ba831f7e11e6974ede4f9fa9fa2714c74db514e0..5b0c48510677a8b4c83e740a8427249f83c60a07 100644 (file)
@@ -40,16 +40,16 @@ import static com.google.common.base.Strings.isNullOrEmpty;
  */
 public class FieldDiffs implements Serializable {
   private static final String CHAR_TO_ESCAPE = "|,{}=:";
-
-  private String issueKey;
-  private String userUuid;
-  private Date creationDate;
   public static final String ASSIGNEE = "assignee";
   public static final String ENCODING_PREFIX = "{base64:";
   public static final String ENCODING_SUFFIX = "}";
 
   private final Map<String, Diff> diffs = new LinkedHashMap<>();
 
+  private String issueKey;
+  private String userUuid;
+  private Date creationDate;
+
   public Map<String, Diff> diffs() {
     if (diffs.containsKey(ASSIGNEE)) {
       Map<String, Diff> result = new LinkedHashMap<>(diffs);
index 9949209e89a281a82144b5c44fd4cd4be2b7d47b..57f087e07bff2328aa18ab555958e3b24f29af2d 100644 (file)
@@ -76,7 +76,7 @@ public class PluginClassloaderFactory {
   /**
    * A plugin can export some resources to other plugins
    */
-  private void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection<PluginClassLoaderDef> allPlugins) {
+  private static void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection<PluginClassLoaderDef> allPlugins) {
     // export the resources to all other plugins
     builder.setExportMask(def.getBasePluginKey(), def.getExportMask());
     for (PluginClassLoaderDef other : allPlugins) {
@@ -89,7 +89,7 @@ public class PluginClassloaderFactory {
   /**
    * Builds classloaders and verifies that all of them are correctly defined
    */
-  private Map<PluginClassLoaderDef, ClassLoader> build(Collection<PluginClassLoaderDef> defs, ClassloaderBuilder builder) {
+  private static Map<PluginClassLoaderDef, ClassLoader> build(Collection<PluginClassLoaderDef> defs, ClassloaderBuilder builder) {
     Map<PluginClassLoaderDef, ClassLoader> result = new HashMap<>();
     Map<String, ClassLoader> classloadersByBasePluginKey = builder.build();
     for (PluginClassLoaderDef def : defs) {
index 2d91fbcdbfc0d244643fcb8308799c533212eb09..ccb255d1808b2e5370d304882bb9aa80f07e506b 100644 (file)
@@ -177,7 +177,7 @@ public class DefaultHttpDownloader extends HttpDownloader {
       initUserAgent(userAgent, config);
     }
 
-    private void initProxy(AuthenticatorFacade system, Configuration config) {
+    private static void initProxy(AuthenticatorFacade system, Configuration config) {
       // register credentials
       Optional<String> login = config.get(HTTP_PROXY_USER);
       if (login.isPresent()) {
index 67847f76c3f3debe03d0a5c0128b5531df4d9f17..65e182b11ebe385bf5017936d9278c509723e588 100644 (file)
@@ -30,18 +30,17 @@ import org.sonar.duplications.utils.FastStringComparator;
  * Set of {@link Block}s, which internally stored as a sorted list.
  */
 final class BlocksGroup {
+  final List<Block> blocks;
 
   /**
    * Factory method.
-   * 
+   *
    * @return new empty group
    */
   public static BlocksGroup empty() {
     return new BlocksGroup();
   }
 
-  protected final List<Block> blocks;
-
   private BlocksGroup() {
     this.blocks = new ArrayList<>();
   }
index 2e4f7c732bb8a2bef834287bfe2d2089bc643599..8df5f6335232892dd3ed21fd1159a14c48be1cee 100644 (file)
@@ -32,10 +32,6 @@ import org.sonar.duplications.token.TokenChunker;
  * </p>
  */
 public final class JavaTokenProducer {
-
-  private JavaTokenProducer() {
-  }
-
   private static final String NORMALIZED_CHARACTER_LITERAL = "$CHARS";
   private static final String NORMALIZED_NUMERIC_LITERAL = "$NUMBER";
 
@@ -45,6 +41,9 @@ public final class JavaTokenProducer {
   private static final String FLOAT_SUFFIX = "[fFdD]";
   private static final String INT_SUFFIX = "[lL]";
 
+  private JavaTokenProducer() {
+  }
+
   public static TokenChunker build() {
     return TokenChunker.builder()
         // White Space
index cd011c8a727042653ae8ec6e9287fff72534a972..20b04ad35b021393e5a96eed2779ff760a81f7f1 100644 (file)
@@ -110,7 +110,7 @@ public class WorkDuration implements Serializable {
    * For instance, 3 days and 4 hours will return 3.5 days (if hoursIndDay is 8).
    */
   public double toWorkingDays() {
-    return durationInMinutes / 60d / hoursInDay;
+    return durationInMinutes / 60D / hoursInDay;
   }
 
   /**
index 50cf9c5810b8bf638a8cc32cb9ee367605dd550e..542f303e3bd24e380cf148772b2ed36ed9a84466 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.api.ce.posttask;
 
-import java.util.Date;
 import java.util.Optional;
 import javax.annotation.CheckForNull;
 import org.sonar.api.ExtensionPoint;
index 2f3397736cbdca06fbd005ade732b75d307b239d..64ac7c8bbcd2557ec23b7ca5a30d711e0f66790c 100644 (file)
@@ -187,6 +187,7 @@ import static org.apache.commons.lang.StringUtils.trim;
 @ServerSide
 @ComputeEngineSide
 @SonarLintSide
+@Deprecated
 public class RulesDefinitionXmlLoader {
 
   private static final String ELEMENT_RULES = "rules";
index 54f511321c67d8f61086c46c7f14c89ede251683..781926a4f457a111fb373c778f33aa9d2482f273 100644 (file)
@@ -222,17 +222,4 @@ public final class ZipUtils {
   public interface ZipEntryFilter {
     boolean accept(ZipEntry entry);
   }
-
-  private static class ZipEntryFilterDelegate implements Predicate<ZipEntry> {
-    private final ZipEntryFilter delegate;
-
-    private ZipEntryFilterDelegate(ZipEntryFilter delegate) {
-      this.delegate = delegate;
-    }
-
-    @Override
-    public boolean test(ZipEntry zipEntry) {
-      return delegate.accept(zipEntry);
-    }
-  }
 }
index d152d2b49905382e0e7bc160a0cb40a2bcc50915..5c775cb2bfab76b82209d8587b0ef3a7244feccd 100644 (file)
@@ -81,7 +81,7 @@ public class TestExecutionPublisher implements ReportPublisherStep {
     appendMeasure(inputFile, writer, new DefaultMeasure<Integer>().forMetric(TEST_FAILURES).withValue((int) failedTests));
   }
 
-  private void appendMeasure(InputFile inputFile, ScannerReportWriter writer, DefaultMeasure measure) {
+  private static void appendMeasure(InputFile inputFile, ScannerReportWriter writer, DefaultMeasure measure) {
     writer.appendComponentMeasure(((DefaultInputComponent) inputFile).scannerId(), toReportMeasure(measure));
   }
 
index 6404d8184dc1b8cb4ce1d31652979b686d349237..f6bf4390ce81616ea0e539c569f3bb4994383a85 100644 (file)
@@ -73,7 +73,7 @@ public class DefaultActiveRulesLoader implements ActiveRulesLoader {
     return ruleList;
   }
 
-  private String getUrl(String qualityProfileKey, int page, int pageSize) {
+  private static String getUrl(String qualityProfileKey, int page, int pageSize) {
     StringBuilder builder = new StringBuilder(1024);
     builder.append(RULES_SEARCH_URL);
     builder.append("&qprofile=").append(ScannerUtils.encodeForUrl(qualityProfileKey));
index 0e3c3f3f401ea938151d58341c7c110c03ca5d9e..7574e75a0c14b84fe5aa080677ab3a4b5c94eb03 100644 (file)
@@ -360,7 +360,7 @@ public class DefaultSensorStorage implements SensorStorage {
     void apply(Integer value, ScannerReport.LineCoverage.Builder builder);
   }
 
-  private void mergeLineCoverageValues(int lineCount, SortedMap<Integer, Integer> valueByLine, SortedMap<Integer, ScannerReport.LineCoverage.Builder> coveragePerLine,
+  private static void mergeLineCoverageValues(int lineCount, SortedMap<Integer, Integer> valueByLine, SortedMap<Integer, ScannerReport.LineCoverage.Builder> coveragePerLine,
     LineCoverageOperation op) {
     for (Map.Entry<Integer, Integer> lineMeasure : valueByLine.entrySet()) {
       int lineIdx = lineMeasure.getKey();
index b6f81481fa4adebd99bac8f85cb9f67763e465d6..c7e651182e2b06d147a2524b7b297453be4de9ec 100644 (file)
@@ -24,11 +24,11 @@ import org.sonar.api.batch.Phase;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
 import org.sonar.api.batch.sensor.coverage.NewCoverage;
 import org.sonar.api.scanner.sensor.ProjectSensor;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.scanner.report.ReportPublisher;
 
 @Phase(name = Phase.Name.POST)
@@ -53,9 +53,7 @@ public final class ZeroCoverageSensor implements ProjectSensor {
         continue;
       }
       if (!isCoverageAlreadyDefined(f)) {
-        ((DefaultInputFile) f).getExecutableLines().ifPresent(execLines -> {
-          storeZeroCoverageForEachExecutableLine(context, f, execLines);
-        });
+        ((DefaultInputFile) f).getExecutableLines().ifPresent(execLines -> storeZeroCoverageForEachExecutableLine(context, f, execLines));
       }
     }
   }
index 6d5c502e447d5f70294018a9fcf7dc120248b288..e12a16279b1d0d8c30b43802b109aa4d8a906b4f 100644 (file)
@@ -55,9 +55,9 @@ public class ActiveRulesProviderTest {
     List<LoadedActiveRule> qp2Rules = ImmutableList.of(r2, r3);
     List<LoadedActiveRule> qp3Rules = ImmutableList.of(r1, r3);
 
-    when(loader.load(eq("qp1"))).thenReturn(qp1Rules);
-    when(loader.load(eq("qp2"))).thenReturn(qp2Rules);
-    when(loader.load(eq("qp3"))).thenReturn(qp3Rules);
+    when(loader.load("qp1")).thenReturn(qp1Rules);
+    when(loader.load("qp2")).thenReturn(qp2Rules);
+    when(loader.load("qp3")).thenReturn(qp3Rules);
 
     QualityProfiles profiles = mockProfiles("qp1", "qp2", "qp3");
     DefaultActiveRules activeRules = provider.provide(loader, profiles);
@@ -66,9 +66,9 @@ public class ActiveRulesProviderTest {
     assertThat(activeRules.findAll()).extracting("ruleKey").containsOnly(
       RuleKey.of("rule1", "rule1"), RuleKey.of("rule2", "rule2"), RuleKey.of("rule3", "rule3"));
 
-    verify(loader).load(eq("qp1"));
-    verify(loader).load(eq("qp2"));
-    verify(loader).load(eq("qp3"));
+    verify(loader).load("qp1");
+    verify(loader).load("qp2");
+    verify(loader).load("qp3");
 
     assertThat(activeRules.getDeprecatedRuleKeys(RuleKey.of("rule1", "rule1"))).containsOnly("rule1old:rule1old");
     verifyNoMoreInteractions(loader);
@@ -81,7 +81,7 @@ public class ActiveRulesProviderTest {
     r2.setParams(ImmutableMap.of("foo1", "bar1", "foo2", "bar2"));
 
     List<LoadedActiveRule> qpRules = ImmutableList.of(r1, r2);
-    when(loader.load(eq("qp"))).thenReturn(qpRules);
+    when(loader.load("qp")).thenReturn(qpRules);
 
     QualityProfiles profiles = mockProfiles("qp");
     ActiveRules activeRules = provider.provide(loader, profiles);
@@ -91,7 +91,7 @@ public class ActiveRulesProviderTest {
       Tuple.tuple(RuleKey.of("rule1", "rule1"), ImmutableMap.of()),
       Tuple.tuple(RuleKey.of("rule2", "rule2"), ImmutableMap.of("foo1", "bar1", "foo2", "bar2")));
 
-    verify(loader).load(eq("qp"));
+    verify(loader).load("qp");
     verifyNoMoreInteractions(loader);
   }
 
index a12bc1f5ef4455c255bbded19102a0cf8c499d2c..98d49ec376a9d0efe657343cad8f57da594aca6a 100644 (file)
@@ -73,7 +73,7 @@ class JsonComparison {
     return compare(expectedJson, actualJson);
   }
 
-  private Object parse(String s) {
+  private static Object parse(String s) {
     try {
       JSONParser parser = new JSONParser();
       return parser.parse(s);
@@ -108,11 +108,11 @@ class JsonComparison {
     return compareBooleans((Boolean) expectedObject, (Boolean) actualObject);
   }
 
-  private boolean compareBooleans(Boolean expected, Boolean actual) {
+  private static boolean compareBooleans(Boolean expected, Boolean actual) {
     return expected.equals(actual);
   }
 
-  private boolean compareNumbers(Number expected, Number actual) {
+  private static boolean compareNumbers(Number expected, Number actual) {
     double d1 = expected.doubleValue();
     double d2 = actual.doubleValue();
     if (Double.compare(d1, d2) == 0) {
index fbb00f7ce5bdeabc2eb6ea251e229082778b120e..457ff104627dd7038f1cc9d7a1fff77fbb29e0a2 100644 (file)
@@ -105,7 +105,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
     return details;
   }
 
-  private void print(String title, SortedMap<String, String> translations, StringBuilder to) {
+  private static void print(String title, SortedMap<String, String> translations, StringBuilder to) {
     if (!translations.isEmpty()) {
       to.append(title);
       for (Map.Entry<String, String> entry : translations.entrySet()) {