-
Couldn't load subscription status.
- Fork 489
[prone] Apply UnnecessaryLambda
#2696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import static java.lang.System.getenv | ||
|
|
||
| apply plugin: 'net.ltgt.errorprone' | ||
|
|
||
| dependencies { | ||
|
|
@@ -9,25 +7,10 @@ dependencies { | |
|
|
||
| tasks.withType(JavaCompile).configureEach { | ||
| options.errorprone { | ||
| disable( // not patchable | ||
| 'FormatStringConcatenation', | ||
| disable( // consider fix, or reasoning. | ||
| 'FunctionalInterfaceMethodChanged', | ||
| 'JavaxInjectOnAbstractMethod', | ||
| 'OverridesJavaxInjectableMethod', | ||
| 'ReturnValueIgnored', | ||
| 'Slf4jLogStatement', | ||
| 'MissingSummary', | ||
| // patchable | ||
| 'LexicographicalAnnotationAttributeListing', | ||
| 'LexicographicalAnnotationListing', | ||
| 'NonStaticImport', | ||
| 'Slf4jLoggerDeclaration', // logger -> log | ||
| 'StaticImport', | ||
| // critical, finds lots of bugs... unused configs and stuff. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too much risk and too big. Some extension maven stuff might be unused in code but break on production. |
||
| 'Unused', | ||
| 'UnusedMethod', | ||
| 'UnusedParameters', | ||
| 'UnusedVariable', | ||
| ) | ||
| error( | ||
| 'AmbiguousJsonCreator', | ||
|
|
@@ -49,45 +32,19 @@ tasks.withType(JavaCompile).configureEach { | |
| 'PrimitiveComparison', | ||
| 'RedundantStringConversion', | ||
| 'RedundantStringEscape', | ||
| 'ReturnValueIgnored', | ||
| 'SelfAssignment', | ||
| 'StringJoin', | ||
| 'StringJoining', | ||
| 'UnnecessarilyFullyQualified', | ||
| 'UnnecessaryLambda', | ||
| ) | ||
| // bug: this only happens when the file is dirty. | ||
| // might be an up2date (caching) issue, as file is currently in corrupt state. | ||
| // ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;) | ||
| errorproneArgs.add('-XepExcludedPaths:' + | ||
| '.*/SelfTest.java|' + | ||
| '.*/GradleIntegrationHarness.java' | ||
| ) | ||
| // fixme bug: this only happens when the file is dirty! | ||
| // up2date checking (caching) must consider file changes, as file is currently corrupt! | ||
| // fix SelfTest.java:L22 ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;) | ||
| errorproneArgs.add('-XepExcludedPaths:.*/SelfTest.java') | ||
| if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) { | ||
| errorproneArgs.addAll( | ||
| '-XepPatchLocation:IN_PLACE', | ||
| '-XepPatchChecks:' + | ||
| 'AmbiguousJsonCreator,' + | ||
| 'ArrayEquals,' + | ||
| 'AssertJNullnessAssertion,' + | ||
| 'AutowiredConstructor,' + | ||
| 'CanonicalAnnotationSyntax,' + | ||
| 'CollectorMutability,' + | ||
| 'ConstantNaming,' + | ||
| 'DirectReturn,' + | ||
| 'EmptyMethod,' + | ||
| 'ExplicitArgumentEnumeration,' + | ||
| 'ExplicitEnumOrdering,' + | ||
| 'FormatStringConcatenation,' + | ||
| 'IdentityConversion,' + | ||
| 'ImmutablesSortedSetComparator,' + | ||
| 'IsInstanceLambdaUsage,' + | ||
| 'MockitoMockClassReference,' + | ||
| 'MockitoStubbing,' + | ||
| 'NestedOptionals,' + | ||
| 'PrimitiveComparison,' + | ||
| 'RedundantStringConversion,' + | ||
| 'RedundantStringEscape,' + | ||
| 'SelfAssignment,' + | ||
| 'Slf4jLogStatement,' + | ||
| 'StringJoin,' + | ||
| 'StringJoining,' + | ||
| 'TimeZoneUsage,' | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright 2016-2021 DiffPlug | ||
| * Copyright 2016-2025 DiffPlug | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -15,6 +15,8 @@ | |
| */ | ||
| package com.diffplug.gradle.spotless; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.nio.charset.Charset; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
@@ -51,7 +53,7 @@ void globalIsRespected() throws Exception { | |
| " encoding 'US-ASCII'", | ||
| "}"); | ||
| setFile("test.java").toContent("µ"); | ||
| gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput().contains("Encoding error!"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use or loose. Should we check this or adapt the test by removing or inverting this? Should we extract the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am baffled by this one. The old test was wrong, but the new one looks wrong too. It would be nice to make this test better while we're in here, but I don't want it to hold up the rest. |
||
| assertThat(gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput()).doesNotContain("Encoding error!"); | ||
| assertFile("test.java").hasContent("µ"); | ||
| } | ||
|
|
||
|
|
@@ -75,7 +77,7 @@ void globalIsRespectedButCanBeOverridden() throws Exception { | |
| "}"); | ||
| setFile("test.java").toContent("µ"); | ||
| setFile("utf32.encoded").toContent("µ", Charset.forName("UTF-32")); | ||
| gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput().contains("Encoding error!"); | ||
| assertThat(gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput()).doesNotContain("Encoding error!"); | ||
| assertFile("test.java").hasContent("µ"); | ||
| assertFile("utf32.encoded").hasContent("µ", Charset.forName("UTF-32")); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now its working as we have enabled convention. the warnings does not break the build somehow.