Skip to content

Commit aff83f8

Browse files
author
Vincent Potucek
committed
[prone] Apply UnnecessaryLambda
1 parent b91580d commit aff83f8

File tree

5 files changed

+15
-29
lines changed

5 files changed

+15
-29
lines changed

gradle/error-prone.gradle

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,10 @@ tasks.withType(JavaCompile).configureEach {
1313
'FormatStringConcatenation',
1414
'FunctionalInterfaceMethodChanged',
1515
'JavaxInjectOnAbstractMethod',
16+
'MissingSummary',
1617
'OverridesJavaxInjectableMethod',
1718
'ReturnValueIgnored',
1819
'Slf4jLogStatement',
19-
'MissingSummary',
20-
// patchable
21-
'LexicographicalAnnotationAttributeListing',
22-
'LexicographicalAnnotationListing',
23-
'NonStaticImport',
24-
'Slf4jLoggerDeclaration', // logger -> log
25-
'StaticImport',
26-
// critical, finds lots of bugs... unused configs and stuff.
27-
'Unused',
28-
'UnusedMethod',
29-
'UnusedParameters',
30-
'UnusedVariable',
3120
)
3221
error(
3322
'AmbiguousJsonCreator',
@@ -41,6 +30,7 @@ tasks.withType(JavaCompile).configureEach {
4130
'ExplicitArgumentEnumeration',
4231
'ExplicitEnumOrdering',
4332
'IdentityConversion',
33+
'UnnecessaryLambda',
4434
'ImmutablesSortedSetComparator',
4535
'IsInstanceLambdaUsage',
4636
'MockitoMockClassReference',
@@ -53,10 +43,9 @@ tasks.withType(JavaCompile).configureEach {
5343
'StringJoin',
5444
'StringJoining',
5545
)
56-
// fixme bug: this only happens when the file is dirty!
57-
// up2date checking (caching) must consider file changes, as file is currently corrupt!
58-
// fix SelfTest.java:L22 ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;)
59-
errorproneArgs.add('-XepExcludedPaths:.*/SelfTest.java')
46+
// bug: this only happens when the file is dirty.
47+
// might be an up2date (caching) issue, as file is currently in corrupt state.
48+
errorproneArgs.add('-XepExcludedPaths:.*/SelfTest.java') // fix: SelfTest.java:L22 ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;)
6049
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
6150
errorproneArgs.addAll(
6251
'-XepPatchLocation:IN_PLACE',
@@ -65,6 +54,7 @@ tasks.withType(JavaCompile).configureEach {
6554
'ArrayEquals,' +
6655
'AssertJNullnessAssertion,' +
6756
'AutowiredConstructor,' +
57+
'UnnecessaryLambda,' +
6858
'CanonicalAnnotationSyntax,' +
6959
'CollectorMutability,' +
7060
'ConstantNaming,' +
@@ -85,8 +75,7 @@ tasks.withType(JavaCompile).configureEach {
8575
'SelfAssignment,' +
8676
'Slf4jLogStatement,' +
8777
'StringJoin,' +
88-
'StringJoining,' +
89-
'TimeZoneUsage,'
78+
'StringJoining,'
9079
)
9180
}
9281
}

lib-extra/src/test/java/com/diffplug/spotless/extra/GitAttributesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2024 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ void policyTest() {
8585
setFile(".gitattributes").toContent(StringPrinter.buildStringFromLines(
8686
"* eol=lf",
8787
"*.MF eol=crlf"));
88-
LineEnding.Policy policy = LineEnding.GIT_ATTRIBUTES.createPolicy(rootFolder(), () -> testFiles());
88+
LineEnding.Policy policy = LineEnding.GIT_ATTRIBUTES.createPolicy(rootFolder(), this::testFiles);
8989
Assertions.assertThat(policy.getEndingFor(newFile("someFile"))).isEqualTo("\n");
9090
Assertions.assertThat(policy.getEndingFor(newFile("subfolder/someFile"))).isEqualTo("\n");
9191
Assertions.assertThat(policy.getEndingFor(newFile("MANIFEST.MF"))).isEqualTo("\r\n");
@@ -100,7 +100,7 @@ void policyDefaultLineEndingTest() throws GitAPIException {
100100
"[core]",
101101
"autocrlf=true",
102102
"eol=lf"));
103-
LineEnding.Policy policy = LineEnding.GIT_ATTRIBUTES.createPolicy(rootFolder(), () -> testFiles());
103+
LineEnding.Policy policy = LineEnding.GIT_ATTRIBUTES.createPolicy(rootFolder(), this::testFiles);
104104
Assertions.assertThat(policy.getEndingFor(newFile("someFile"))).isEqualTo("\r\n");
105105
}
106106

plugin-maven/src/main/java/com/diffplug/spotless/maven/ArtifactResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Set<File> resolve(boolean withTransitives, Collection<String> mavenCoordi
6666
excludeTransitive.add(EXCLUDE_ALL_TRANSITIVES);
6767
}
6868
List<Dependency> dependencies = mavenCoordinates.stream()
69-
.map(coordinateString -> new DefaultArtifact(coordinateString))
69+
.map(DefaultArtifact::new)
7070
.map(artifact -> new Dependency(artifact, null, null, excludeTransitive))
7171
.collect(toList());
7272
CollectRequest collectRequest = new CollectRequest(dependencies, null, repositories);

testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,16 @@ public static Provisioner mavenCentral() {
143143
return MAVEN_CENTRAL.get();
144144
}
145145

146-
private static final Supplier<Provisioner> MAVEN_CENTRAL = Suppliers.memoize(() -> caching("mavenCentral", () -> createWithRepositories(repo -> repo.mavenCentral())));
146+
private static final Supplier<Provisioner> MAVEN_CENTRAL = Suppliers.memoize(() -> caching("mavenCentral", () -> createWithRepositories(RepositoryHandler::mavenCentral)));
147147

148148
/** Creates a Provisioner for the local maven repo for development purpose. */
149149
public static Provisioner mavenLocal() {
150-
return MAVEN_LOCAL.get();
150+
return createWithRepositories(RepositoryHandler::mavenLocal);
151151
}
152152

153-
private static final Supplier<Provisioner> MAVEN_LOCAL = () -> createWithRepositories(repo -> repo.mavenLocal());
154-
155153
/** Creates a Provisioner for the Sonatype snapshots maven repo for development purpose. */
156154
public static Provisioner snapshots() {
157-
return SNAPSHOTS.get();
155+
return createWithRepositories(repo -> repo.maven(setup -> setup.setUrl("https://oss.sonatype.org/content/repositories/snapshots")));
158156
}
159157

160-
private static final Supplier<Provisioner> SNAPSHOTS = () -> createWithRepositories(repo -> repo.maven(setup -> setup.setUrl("https://oss.sonatype.org/content/repositories/snapshots")));
161158
}

testlib/src/test/java/com/diffplug/spotless/FormatterPropertiesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public FormatterSettingsAssert(FormatterProperties actual) {
196196

197197
/** Check that the values form all valid files are part of the settings properties. */
198198
public FormatterSettingsAssert containsSpecificValuesOf(Collection<File> files) {
199-
files.forEach(file -> containsSpecificValuesOf(file));
199+
files.forEach(this::containsSpecificValuesOf);
200200
return this;
201201
}
202202

0 commit comments

Comments
 (0)