aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-09-23 11:16:04 -0500
committersonartech <sonartech@sonarsource.com>2021-09-24 20:03:10 +0000
commit215f8403a6c4a131b9592457fd95a280274237de (patch)
tree9412c0030b97b4e40563a882ababea60189270c6 /sonar-scanner-engine
parent5377194709960576b1367a220c6ba20ce6f41ef0 (diff)
downloadsonarqube-215f8403a6c4a131b9592457fd95a280274237de.tar.gz
sonarqube-215f8403a6c4a131b9592457fd95a280274237de.zip
Fix code quality issues
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/TestExecutionPublisher.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/source/ZeroCoverageSensor.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/ActiveRulesProviderTest.java16
5 files changed, 13 insertions, 15 deletions
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<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));
}
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<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();
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<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);
}