Polish "Use Stream.toList()"

See gh-36167
pull/37018/head
Andy Wilkinson 1 year ago
parent 0fa58c04e7
commit 0e815d2342

@ -21,6 +21,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.base.DescribedPredicate;
@ -74,7 +75,7 @@ public abstract class ArchitectureCheck extends DefaultTask {
allBeanPostProcessorBeanMethodsShouldBeStaticAndHaveParametersThatWillNotCausePrematureInitialization(), allBeanPostProcessorBeanMethodsShouldBeStaticAndHaveParametersThatWillNotCausePrematureInitialization(),
allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters(), allBeanFactoryPostProcessorBeanMethodsShouldBeStaticAndHaveNoParameters(),
noClassesShouldCallStepVerifierStepVerifyComplete(), noClassesShouldCallStepVerifierStepVerifyComplete(),
noClassesShouldConfigureDefaultStepVerifierTimeout()) noClassesShouldConfigureDefaultStepVerifierTimeout(), noClassesShouldCallCollectorsToList())
.map((rule) -> rule.evaluate(javaClasses)) .map((rule) -> rule.evaluate(javaClasses))
.filter(EvaluationResult::hasViolation) .filter(EvaluationResult::hasViolation)
.toList(); .toList();
@ -177,6 +178,13 @@ public abstract class ArchitectureCheck extends DefaultTask {
.because("expectComplete().verify(Duration) should be used instead"); .because("expectComplete().verify(Duration) should be used instead");
} }
private ArchRule noClassesShouldCallCollectorsToList() {
return ArchRuleDefinition.noClasses()
.should()
.callMethod(Collectors.class, "toList")
.because("java.util.stream.Stream.toList() should be used instead");
}
public void setClasses(FileCollection classes) { public void setClasses(FileCollection classes) {
this.classes = classes; this.classes = classes;
} }

Loading…
Cancel
Save