From: Duarte Meneses
Date: Thu, 23 Sep 2021 16:16:04 +0000 (-0500)
Subject: Fix code quality issues
X-Git-Tag: 9.2.0.49834~202
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=215f8403a6c4a131b9592457fd95a280274237de;p=sonarqube.git
Fix code quality issues
---
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
index bafc40cf4ef..b3386eca505 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoader.java
@@ -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;
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolver.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolver.java
index f40b03d38ff..c2a2ad9f063 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolver.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolver.java
@@ -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());
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java
index 505e53851b3..921fc7ea48a 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/CommentMeasuresStep.java
@@ -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()));
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java
index 6a33321b52b..8b49a05d829 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java
@@ -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());
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java
index eb1d1bae893..1dc926c495b 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/UnitTestMeasuresStep.java
@@ -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();
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/RegisterQualityProfileStatusStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/RegisterQualityProfileStatusStepTest.java
index c55beae60e7..d43e8caacca 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/RegisterQualityProfileStatusStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/RegisterQualityProfileStatusStepTest.java
@@ -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);
}
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
index d3ebb0fec99..67d93e29347 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java
@@ -102,7 +102,7 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue
}
}
- private Optional findPendingTask(String workerUuid, DbSession dbSession, CeQueueDao ceQueueDao, boolean excludeIndexationJob) {
+ private static Optional 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
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleMetadataDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleMetadataDto.java
index 19eab9689ea..1a67185b9b6 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleMetadataDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleMetadataDto.java
@@ -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;
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilder.java
index 5b0315d8d1c..3ae34aad1be 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilder.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AlterColumnsBuilder.java
@@ -115,16 +115,6 @@ public class AlterColumnsBuilder {
return sqls;
}
- private void addColumns(StringBuilder sql, String updateKeyword, String typePrefix, boolean addNotNullableProperty) {
- for (Iterator 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(" ")
diff --git a/server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java b/server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java
index b1cf76d4a3c..bc183577bd4 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/config/JdbcSettings.java
@@ -142,16 +142,4 @@ public class JdbcSettings implements Consumer {
}
}
}
-
- 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);
- }
- }
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
index 09439d9cbab..817344f235b 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
@@ -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
+ }
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java
index 9873b57e302..8a4cee79eb3 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java
@@ -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 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));
}
};
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
index 73c7d7a0f80..dd1c529d799 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java
@@ -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;
}
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java
index e202dfa94df..7f3f8d34678 100644
--- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java
+++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java
@@ -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 incompatiblePlugins = plugins.stream()
.filter(p -> FORBIDDEN_INCOMPATIBLE_PLUGINS.contains(p.getKey()))
.map(p -> "'" + p.getKey() + "'")
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImpl.java
index 207d2736f27..dba73b81525 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImpl.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2AuthenticationParametersImpl.java
@@ -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>() {
}.getType();
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
index 6c45615d3bf..503b8be6149 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
@@ -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
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/ResetPasswordFilterTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/ResetPasswordFilterTest.java
index 8a0dd6ac2b7..319b9a27bf4 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/ResetPasswordFilterTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/ResetPasswordFilterTest.java
@@ -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
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/AbstractSystemInfoWriter.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/AbstractSystemInfoWriter.java
index 95f556a3c34..aff00e45cf1 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/AbstractSystemInfoWriter.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/AbstractSystemInfoWriter.java
@@ -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());
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
index 8d33e4bd20c..69e561a4a40 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/CommonRuleDefinitionsImpl.java
@@ -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);
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
index 1760041827b..4a37f07d284 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/startup/RegisterMetrics.java
@@ -124,7 +124,7 @@ public class RegisterMetrics implements Startable {
return metricsToRegister;
}
- private void checkMetrics(Map metricsByRepository, Metrics metrics) {
+ private static void checkMetrics(Map metricsByRepository, Metrics metrics) {
for (Metric metric : metrics.getMetrics()) {
String metricKey = metric.getKey();
if (CoreMetrics.getMetrics().contains(metric)) {
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
index 48082da3e9d..ed80458dd0e 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java
@@ -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);
}
}
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectsTextSearchQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectsTextSearchQueryFactory.java
index d8884fb0de6..be9f6f529fa 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectsTextSearchQueryFactory.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectsTextSearchQueryFactory.java
@@ -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);
}
};
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposAction.java
index f9a295db803..99bd317ed4d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/bitbucketserver/SearchBitbucketServerReposAction.java
@@ -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";
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
index 5b446821cc1..95dd958a4d7 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
@@ -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;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
index d5036078e1d..3ffa358b4bc 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectDataLoader.java
@@ -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.");
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/InfoAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/InfoAction.java
index ce0c5092b0f..326b7414cfa 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/InfoAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/InfoAction.java
@@ -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;
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 d05d9d1eaca..f56a6a6a370 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
@@ -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();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/AbstractChangeTagsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/AbstractChangeTagsAction.java
index 99cc063b64d..357a9bdb6a3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/AbstractChangeTagsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/AbstractChangeTagsAction.java
@@ -65,7 +65,7 @@ public abstract class AbstractChangeTagsAction extends Action {
return false;
}
- private Set parseTags(Map properties) {
+ private static Set parseTags(Map properties) {
Set result = new HashSet<>();
String tagsString = (String) properties.get(TAGS_PARAMETER);
if (!Strings.isNullOrEmpty(tagsString)) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
index 383de3a2800..cbb16109ba2 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentAction.java
@@ -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;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
index e56d72b6770..cfd5dd1150c 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/ComponentTreeAction.java
@@ -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 measures,
- Map referenceComponentsByUuid) {
+ Map 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 searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent,
- ComponentTreeQuery componentTreeQuery, List components, List metrics) {
+ ComponentTreeQuery componentTreeQuery, List components, List metrics) {
Map metricsByUuid = Maps.uniqueIndex(metrics, MetricDto::getUuid);
MeasureTreeQuery measureQuery = MeasureTreeQuery.builder()
@@ -534,7 +534,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
*
*/
private static void addBestValuesToMeasures(Table measuresByComponentUuidAndMetric, List components,
- List metrics) {
+ List metrics) {
List metricDtosWithBestValueMeasure = metrics.stream()
.filter(MetricDtoFunctions.isOptimizedForBestValue())
.map(new MetricDtoToMetricDtoWithBestValue())
@@ -555,7 +555,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
}
private static List filterComponents(List components,
- Table measuresByComponentUuidAndMetric, List metrics, ComponentTreeRequest wsRequest) {
+ Table measuresByComponentUuidAndMetric, List metrics, ComponentTreeRequest wsRequest) {
if (!componentWithMeasuresOnly(wsRequest)) {
return components;
}
@@ -575,7 +575,7 @@ public class ComponentTreeAction implements MeasuresWsAction {
}
private static List sortComponents(List components, ComponentTreeRequest wsRequest, List metrics,
- Table measuresByComponentUuidAndMetric) {
+ Table measuresByComponentUuidAndMetric) {
return ComponentTreeSort.sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java
index b51fd838d6f..54b2c6e89a1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/MeasureValueFormatter.java
@@ -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) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/DecorationDataHolder.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/DecorationDataHolder.java
index 56ed04e44f3..f0d69ff263a 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/DecorationDataHolder.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/DecorationDataHolder.java
@@ -112,7 +112,7 @@ class DecorationDataHolder {
}
}
- private void insertAndPreserveOrder(OpeningHtmlTag newEntry, List openingHtmlTags) {
+ private static void insertAndPreserveOrder(OpeningHtmlTag newEntry, List openingHtmlTags) {
int insertionIndex = 0;
Iterator 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 orderedOffsets) {
+ private static void insertAndPreserveOrder(int newOffset, List orderedOffsets) {
int insertionIndex = 0;
Iterator entriesIterator = orderedOffsets.iterator();
while (entriesIterator.hasNext() && entriesIterator.next() <= newOffset) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/HtmlTextDecorator.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/HtmlTextDecorator.java
index 8b9eb59b1a2..1449e98f779 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/HtmlTextDecorator.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/HtmlTextDecorator.java
@@ -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 getTagsToOpen(int currentIndex, DecorationDataHolder dataHolder) {
+ private static Collection getTagsToOpen(int currentIndex, DecorationDataHolder dataHolder) {
Collection 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 tagsToOpen,
+ private static void openNewTags(CharactersReader charactersReader, Collection 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("");
}
- private void injectClosingHtml(StringBuilder decoratedText) {
+ private static void injectClosingHtml(StringBuilder decoratedText) {
decoratedText.append("");
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
index 458cf2db55a..19bb7c6b2b0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
@@ -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
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
index 1c0a44ac999..b5b66edd5dc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
@@ -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
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
index dfc9a5cfaa5..7c4189fc497 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java
@@ -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
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/PlatformServletContextListener.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/PlatformServletContextListener.java
index cfe7606bbf2..e5ba5fff40c 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/PlatformServletContextListener.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/PlatformServletContextListener.java
@@ -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
index fa6809cc717..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java
+++ /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);
- }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/FieldDiffs.java b/sonar-core/src/main/java/org/sonar/core/issue/FieldDiffs.java
index ba831f7e11e..5b0c4851067 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/FieldDiffs.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/FieldDiffs.java
@@ -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 diffs = new LinkedHashMap<>();
+ private String issueKey;
+ private String userUuid;
+ private Date creationDate;
+
public Map diffs() {
if (diffs.containsKey(ASSIGNEE)) {
Map result = new LinkedHashMap<>(diffs);
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
index 9949209e89a..57f087e07bf 100644
--- a/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
+++ b/sonar-core/src/main/java/org/sonar/core/platform/PluginClassloaderFactory.java
@@ -76,7 +76,7 @@ public class PluginClassloaderFactory {
/**
* A plugin can export some resources to other plugins
*/
- private void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection allPlugins) {
+ private static void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection 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 build(Collection defs, ClassloaderBuilder builder) {
+ private static Map build(Collection defs, ClassloaderBuilder builder) {
Map result = new HashMap<>();
Map classloadersByBasePluginKey = builder.build();
for (PluginClassLoaderDef def : defs) {
diff --git a/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java b/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
index 2d91fbcdbfc..ccb255d1808 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
@@ -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 login = config.get(HTTP_PROXY_USER);
if (login.isPresent()) {
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java b/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
index 67847f76c3f..65e182b11eb 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/detector/original/BlocksGroup.java
@@ -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 blocks;
/**
* Factory method.
- *
+ *
* @return new empty group
*/
public static BlocksGroup empty() {
return new BlocksGroup();
}
- protected final List blocks;
-
private BlocksGroup() {
this.blocks = new ArrayList<>();
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/java/JavaTokenProducer.java b/sonar-duplications/src/main/java/org/sonar/duplications/java/JavaTokenProducer.java
index 2e4f7c732bb..8df5f633523 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/java/JavaTokenProducer.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/java/JavaTokenProducer.java
@@ -32,10 +32,6 @@ import org.sonar.duplications.token.TokenChunker;
*
*/
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
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
index cd011c8a727..20b04ad35b0 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/utils/WorkDuration.java
@@ -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;
}
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java
index 50cf9c5810b..542f303e3bd 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java
@@ -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;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
index 2f3397736cb..64ac7c8bbcd 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
@@ -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";
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
index 54f511321c6..781926a4f45 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
@@ -222,17 +222,4 @@ public final class ZipUtils {
public interface ZipEntryFilter {
boolean accept(ZipEntry entry);
}
-
- private static class ZipEntryFilterDelegate implements Predicate {
- private final ZipEntryFilter delegate;
-
- private ZipEntryFilterDelegate(ZipEntryFilter delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public boolean test(ZipEntry zipEntry) {
- return delegate.accept(zipEntry);
- }
- }
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java
index d152d2b4990..5c775cb2bfa 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java
@@ -81,7 +81,7 @@ public class TestExecutionPublisher implements ReportPublisherStep {
appendMeasure(inputFile, writer, new DefaultMeasure().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));
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
index 6404d8184dc..f6bf4390ce8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
@@ -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));
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
index 0e3c3f3f401..7574e75a0c1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
@@ -360,7 +360,7 @@ public class DefaultSensorStorage implements SensorStorage {
void apply(Integer value, ScannerReport.LineCoverage.Builder builder);
}
- private void mergeLineCoverageValues(int lineCount, SortedMap valueByLine, SortedMap coveragePerLine,
+ private static void mergeLineCoverageValues(int lineCount, SortedMap valueByLine, SortedMap coveragePerLine,
LineCoverageOperation op) {
for (Map.Entry lineMeasure : valueByLine.entrySet()) {
int lineIdx = lineMeasure.getKey();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java
index b6f81481fa4..c7e651182e2 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java
@@ -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));
}
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
index 6d5c502e447..e12a16279b1 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java
@@ -55,9 +55,9 @@ public class ActiveRulesProviderTest {
List qp2Rules = ImmutableList.of(r2, r3);
List 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 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);
}
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
index a12bc1f5ef4..98d49ec376a 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java
@@ -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) {
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
index fbb00f7ce5b..457ff104627 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
@@ -105,7 +105,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher {
return details;
}
- private void print(String title, SortedMap translations, StringBuilder to) {
+ private static void print(String title, SortedMap translations, StringBuilder to) {
if (!translations.isEmpty()) {
to.append(title);
for (Map.Entry entry : translations.entrySet()) {