aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis
diff options
context:
space:
mode:
authorJulien Camus <julien.camus@sonarsource.com>2024-12-17 17:37:43 +0100
committerSteve Marion <steve.marion@sonarsource.com>2024-12-18 11:13:24 +0100
commit108e25bce0062be83ab15c587aecfa1e51ba5cf1 (patch)
tree8102236ce649305a1d270a56cc284d5d12a4c31c /server/sonar-ce-task-projectanalysis
parent16e6a0469c02298a8b5c478313dd68c93705922e (diff)
downloadsonarqube-108e25bce0062be83ab15c587aecfa1e51ba5cf1.tar.gz
sonarqube-108e25bce0062be83ab15c587aecfa1e51ba5cf1.zip
SONAR-24004 Replace lambda with method reference
Diffstat (limited to 'server/sonar-ce-task-projectanalysis')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorIT.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/NewSizeMeasuresStep.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java2
5 files changed, 13 insertions, 11 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorIT.java
index 4327e98bad7..dcd42febcb9 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorIT.java
@@ -30,6 +30,7 @@ import org.sonar.api.utils.System2;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
+import org.sonar.db.issue.ImpactDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.scanner.protocol.Constants;
import org.sonar.scanner.protocol.output.ScannerReport;
@@ -71,7 +72,7 @@ public class AdHocRuleCreatorIT {
assertThat(rule.getAdHocSeverity()).isNull();
assertThat(rule.getAdHocType()).isNull();
assertThat(rule.getCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.defaultCleanCodeAttribute());
- assertThat(rule.getDefaultImpacts()).extracting(i -> i.getSoftwareQuality(), i -> i.getSeverity())
+ assertThat(rule.getDefaultImpacts()).extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
.containsExactly(Tuple.tuple(SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.MEDIUM));
}
@@ -105,7 +106,7 @@ public class AdHocRuleCreatorIT {
assertThat(rule.getAdHocSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(rule.getAdHocType()).isEqualTo(RuleType.BUG.getDbConstant());
assertThat(rule.getCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.DISTINCT);
- assertThat(rule.getDefaultImpacts()).extracting(i -> i.getSoftwareQuality(), i -> i.getSeverity())
+ assertThat(rule.getDefaultImpacts()).extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
.containsExactly(tuple(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW));
}
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 fc33b908e16..38dd2250a36 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
@@ -76,7 +76,7 @@ public class NewSizeMeasuresStep implements ComputationStep {
new PathAwareCrawler<>(
FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(List.of(duplicationFormula)))
- .visit(treeRootHolder.getRoot());
+ .visit(treeRootHolder.getRoot());
}
private static class NewSizeCounter implements Counter<NewSizeCounter> {
@@ -131,7 +131,7 @@ public class NewSizeMeasuresStep implements ComputationStep {
duplicationCounters.addBlock(duplication.getOriginal());
Arrays.stream(duplication.getDuplicates())
.filter(InnerDuplicate.class::isInstance)
- .map(duplicate -> (InnerDuplicate) duplicate)
+ .map(InnerDuplicate.class::cast)
.forEach(duplicate -> duplicationCounters.addBlock(duplicate.getTextBlock()));
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
index dbd6a1cf073..646061b3525 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
@@ -209,7 +209,8 @@ class TrackerRawInputFactoryTest {
assertThat(locations.getFlow(0).getLocation(0).getMsg()).isEqualTo("loc1");
assertThat(locations.getFlow(0).getLocation(0).getMsgFormattingCount()).isEqualTo(1);
- assertThat(locations.getFlow(0).getLocation(0).getMsgFormatting(0)).extracting(m -> m.getStart(), m -> m.getEnd(), m -> m.getType())
+ assertThat(locations.getFlow(0).getLocation(0).getMsgFormatting(0))
+ .extracting(DbIssues.MessageFormatting::getStart, DbIssues.MessageFormatting::getEnd, DbIssues.MessageFormatting::getType)
.containsExactly(0, 4, DbIssues.MessageFormattingType.CODE);
assertThat(locations.getFlow(1).hasDescription()).isFalse();
@@ -395,8 +396,7 @@ class TrackerRawInputFactoryTest {
Arguments.of(IssueType.CODE_SMELL, RuleType.CODE_SMELL, STATUS_OPEN),
Arguments.of(IssueType.BUG, RuleType.BUG, STATUS_OPEN),
Arguments.of(IssueType.VULNERABILITY, RuleType.VULNERABILITY, STATUS_OPEN),
- Arguments.of(IssueType.SECURITY_HOTSPOT, RuleType.SECURITY_HOTSPOT, STATUS_TO_REVIEW)
- );
+ Arguments.of(IssueType.SECURITY_HOTSPOT, RuleType.SECURITY_HOTSPOT, STATUS_TO_REVIEW));
}
@ParameterizedTest
@@ -570,7 +570,8 @@ class TrackerRawInputFactoryTest {
}
private void registerRule(RuleKey ruleKey, String name) {
- registerRule(ruleKey, name, r -> {});
+ registerRule(ruleKey, name, r -> {
+ });
}
private void registerRule(RuleKey ruleKey, String name, Consumer<DumbRule> dumbRulePopulator) {
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
index b695087fb7f..26747289941 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
@@ -92,7 +92,7 @@ public class MapBasedRawMeasureRepositoryTest {
@Test
public void add_throws_NPE_if_Component_argument_is_null() {
- assertThatThrownBy(() -> underTest.add(null, metric1, SOME_MEASURE))
+ assertThatThrownBy(() -> underTest.add(null, metric1, SOME_MEASURE))
.isInstanceOf(NullPointerException.class);
}
@@ -153,7 +153,7 @@ public class MapBasedRawMeasureRepositoryTest {
public static Object[][] measures() {
return MEASURES.stream()
.map(c -> new Measure[] {c})
- .toArray(i -> new Object[i][]);
+ .toArray(Object[][]::new);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java
index 27e05834df3..58747ebe4cc 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateMeasuresStepTest.java
@@ -145,7 +145,7 @@ class QualityGateMeasuresStepTest {
underTest.execute(new TestComputationStepContext());
- assertThatThrownBy(() -> qualityGateStatusHolder.getStatus())
+ assertThatThrownBy(qualityGateStatusHolder::getStatus)
.isInstanceOf(IllegalStateException.class)
.hasMessage("Quality gate status has not been set yet");
}