Skip to content

Commit 4fca955

Browse files
author
Vincent Potucek
committed
[prone] Apply UnusedMethod
1 parent b91580d commit 4fca955

File tree

28 files changed

+44
-223
lines changed

28 files changed

+44
-223
lines changed

gradle/error-prone.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ tasks.withType(JavaCompile).configureEach {
2323
'NonStaticImport',
2424
'Slf4jLoggerDeclaration', // logger -> log
2525
'StaticImport',
26-
// critical, finds lots of bugs... unused configs and stuff.
27-
'Unused',
28-
'UnusedMethod',
29-
'UnusedParameters',
30-
'UnusedVariable',
3126
)
3227
error(
3328
'AmbiguousJsonCreator',
@@ -52,11 +47,15 @@ tasks.withType(JavaCompile).configureEach {
5247
'SelfAssignment',
5348
'StringJoin',
5449
'StringJoining',
50+
'Unused',
5551
)
5652
// fixme bug: this only happens when the file is dirty!
5753
// up2date checking (caching) must consider file changes, as file is currently corrupt!
5854
// fix SelfTest.java:L22 ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;)
5955
errorproneArgs.add('-XepExcludedPaths:.*/SelfTest.java')
56+
// bug https://github.com/google/error-prone/issues/5289
57+
errorproneArgs.add('-XepExcludedPaths:.*/EclipseJdtFormatterStepTest.java')
58+
errorproneArgs.add('-XepExcludedPaths:.*/JvmTest.java')
6059
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
6160
errorproneArgs.addAll(
6261
'-XepPatchLocation:IN_PLACE',
@@ -86,7 +85,10 @@ tasks.withType(JavaCompile).configureEach {
8685
'Slf4jLogStatement,' +
8786
'StringJoin,' +
8887
'StringJoining,' +
89-
'TimeZoneUsage,'
88+
'TimeZoneUsage,' +
89+
'UnusedMethod,' +
90+
'UnusedParameters,' +
91+
'UnusedVariable,'
9092
)
9193
}
9294
}

lib-extra/src/test/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStepTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,5 @@ void formatWithVersion(String version) throws Exception {
3636
"#include <a.h>;\nint main(int argc, char *argv[]) {\n}\n");
3737
}
3838

39-
private static Stream<String> formatWithVersion() {
40-
return Stream.of("11.0", "11.6", EclipseCdtFormatterStep.defaultVersion());
41-
}
39+
4240
}

lib-extra/src/test/java/com/diffplug/spotless/extra/groovy/GrEclipseFormatterStepTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import com.diffplug.spotless.extra.eclipse.EquoResourceHarness;
2525

2626
public class GrEclipseFormatterStepTest extends EquoResourceHarness {
27-
private static final String INPUT = "class F{ def m(){} }";
28-
private static final String EXPECTED = "class F{\n\tdef m(){}\n}";
27+
28+
2929

3030
public GrEclipseFormatterStepTest() {
3131
super(GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral()));
@@ -38,7 +38,5 @@ void formatWithVersion(String version) throws Exception {
3838
"class F{ def m(){} }", "class F{\n\tdef m(){}\n}");
3939
}
4040

41-
private static Stream<String> formatWithVersion() {
42-
return Stream.of("4.18", GrEclipseFormatterStep.defaultVersion());
43-
}
41+
4442
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ void formatWithVersion(String version) throws Exception {
4343
"package p;\nclass C {\n}");
4444
}
4545

46-
private static Stream<String> formatWithVersion() {
47-
return Stream.of("4.9", EclipseJdtFormatterStep.defaultVersion());
48-
}
46+
4947

5048
/** New format interface requires source file information to distinguish module-info from compilation unit */
5149
@Nested

lib-extra/src/test/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStepTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ void formatWithVersion(String version) throws Exception {
5252
harnessFor(version).test("someFilename", unformatted, formatted);
5353
}
5454

55-
private static Stream<String> formatWithVersion() {
56-
return Stream.of(JVM_SUPPORT.getRecommendedFormatterVersion(), EclipseWtpFormatterStep.defaultVersion());
57-
}
55+
5856

5957
/**
6058
* Check that configuration change is supported by all WTP formatters.

lib/src/compatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0Adapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
import java.util.stream.Collectors;
2828
import java.util.stream.Stream;
2929

30-
import org.slf4j.Logger;
31-
import org.slf4j.LoggerFactory;
32-
3330
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
3431
import com.pinterest.ktlint.rule.engine.api.Code;
3532
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
@@ -55,8 +52,6 @@
5552

5653
public class KtLintCompat0Dot49Dot0Adapter implements KtLintCompatAdapter {
5754

58-
private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot49Dot0Adapter.class);
59-
6055
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;
6156

6257
static {

lib/src/compatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0Adapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import java.util.stream.Collectors;
2626
import java.util.stream.Stream;
2727

28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
30-
3128
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
3229
import com.pinterest.ktlint.rule.engine.api.Code;
3330
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
@@ -55,8 +52,6 @@
5552

5653
public class KtLintCompat0Dot50Dot0Adapter implements KtLintCompatAdapter {
5754

58-
private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot50Dot0Adapter.class);
59-
6055
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;
6156

6257
static {

lib/src/compatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0Adapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
import java.util.stream.Collectors;
2525
import java.util.stream.Stream;
2626

27-
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
29-
3027
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
3128
import com.pinterest.ktlint.rule.engine.api.Code;
3229
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
@@ -54,8 +51,6 @@
5451

5552
public class KtLintCompat1Dot0Dot0Adapter implements KtLintCompatAdapter {
5653

57-
private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat1Dot0Dot0Adapter.class);
58-
5954
private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;
6055

6156
static {

lib/src/gherkin/java/com/diffplug/spotless/glue/gherkin/GherkinUtilsFormatterFunc.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -15,9 +15,6 @@
1515
*/
1616
package com.diffplug.spotless.glue.gherkin;
1717

18-
import org.slf4j.Logger;
19-
import org.slf4j.LoggerFactory;
20-
2118
import com.diffplug.spotless.FormatterFunc;
2219
import com.diffplug.spotless.gherkin.GherkinUtilsConfig;
2320

@@ -30,12 +27,9 @@
3027
import io.cucumber.messages.types.SourceMediaType;
3128

3229
public class GherkinUtilsFormatterFunc implements FormatterFunc {
33-
private static final Logger LOGGER = LoggerFactory.getLogger(GherkinUtilsFormatterFunc.class);
34-
35-
private final GherkinUtilsConfig gherkinSimpleConfig;
3630

3731
public GherkinUtilsFormatterFunc(GherkinUtilsConfig gherkinSimpleConfig) {
38-
this.gherkinSimpleConfig = gherkinSimpleConfig;
32+
3933
}
4034

4135
// Follows https://github.com/cucumber/gherkin-utils/blob/main/java/src/test/java/io/cucumber/gherkin/utils/pretty/PrettyTest.java

lib/src/googleJavaFormat/java/com/diffplug/spotless/glue/java/GoogleJavaFormatRemoveUnusedImporterFormatterFunc.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 DiffPlug
2+
* Copyright 2023-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.
@@ -15,8 +15,6 @@
1515
*/
1616
package com.diffplug.spotless.glue.java;
1717

18-
import java.util.Objects;
19-
2018
import javax.annotation.Nonnull;
2119

2220
import com.google.googlejavaformat.java.RemoveUnusedImports;
@@ -25,11 +23,8 @@
2523

2624
public class GoogleJavaFormatRemoveUnusedImporterFormatterFunc implements FormatterFunc {
2725

28-
@Nonnull
29-
private final String version;
30-
3126
public GoogleJavaFormatRemoveUnusedImporterFormatterFunc(@Nonnull String version) {
32-
this.version = Objects.requireNonNull(version);
27+
3328
}
3429

3530
@Override

0 commit comments

Comments
 (0)