Skip to content

Commit 65b2c13

Browse files
author
Vincent Potucek
committed
[prone] Apply UnusedMethod
1 parent b91580d commit 65b2c13

File tree

15 files changed

+27
-198
lines changed

15 files changed

+27
-198
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 @MethodSource
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/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

lib/src/main/java/com/diffplug/spotless/generic/ReplaceRegexStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ private static final class LintState implements Serializable {
6868
private static final long serialVersionUID = 1L;
6969

7070
private final Pattern regex;
71-
private final String ruleId;
71+
7272
private final String lintDetail;
7373

7474
LintState(Pattern regex, String ruleId, String lintDetail) {
7575
this.regex = regex;
76-
this.ruleId = ruleId;
76+
7777
this.lintDetail = lintDetail;
7878
}
7979

lib/src/main/java/com/diffplug/spotless/java/PalantirJavaFormatStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ private static final class State implements Serializable {
111111
private static final long serialVersionUID = 1L;
112112

113113
private final JarState jarState;
114-
private final String formatterVersion;
114+
115115
private final String style;
116116
private final boolean formatJavadoc;
117117

118118
State(JarState jarState, String formatterVersion, String style, boolean formatJavadoc) {
119119
ModuleHelper.doOpenInternalPackagesIfRequired();
120120
this.jarState = jarState;
121-
this.formatterVersion = formatterVersion;
121+
122122
this.style = style;
123123
this.formatJavadoc = formatJavadoc;
124124
}

lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,15 @@ abstract class NpmFormatterStepStateBase implements Serializable {
4141

4242
private static final Logger LOGGER = LoggerFactory.getLogger(NpmFormatterStepStateBase.class);
4343

44-
private static final TimedLogger TIMED_LOGGER = TimedLogger.forLogger(LOGGER);
45-
4644
@Serial
4745
private static final long serialVersionUID = 1460749955865959948L;
4846

49-
private final String stepName;
5047
private final NpmConfig npmConfig;
5148

5249
public final NpmFormatterStepLocations locations;
5350

5451
protected NpmFormatterStepStateBase(String stepName, NpmConfig npmConfig, NpmFormatterStepLocations locations) throws IOException {
55-
this.stepName = requireNonNull(stepName);
52+
5653
this.npmConfig = requireNonNull(npmConfig);
5754
this.locations = locations;
5855
}

lib/src/main/java/com/diffplug/spotless/rdf/RdfFormatterFunc.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public String apply(String rawUnix, File file) throws Exception {
6464
return formatTurtle(rawUnix, file, reflectionHelper);
6565
}
6666
if (TRIG_EXTENSIONS.contains(extension)) {
67-
return formatTrig(rawUnix, file);
67+
return formatTrig(file);
6868
}
6969
if (NTRIPLES_EXTENSIONS.contains(extension)) {
70-
return formatNTriples(rawUnix, file);
70+
return formatNTriples(file);
7171
}
7272
if (NQUADS_EXTENSIONS.contains(extension)) {
73-
return formatNQuads(rawUnix, file);
73+
return formatNQuads(rawUnix);
7474
}
7575
throw new IllegalArgumentException("Cannot handle file with extension %s".formatted(extension));
7676
} catch (InvocationTargetException e) {
@@ -80,15 +80,15 @@ public String apply(String rawUnix, File file) throws Exception {
8080
}
8181
}
8282

83-
private String formatNQuads(String rawUnix, File file) {
83+
private String formatNQuads(String rawUnix) {
8484
throw new UnsupportedOperationException("NQUADS formatting not supported yet");
8585
}
8686

87-
private String formatNTriples(String rawUnix, File file) {
87+
private String formatNTriples(File file) {
8888
throw new UnsupportedOperationException("NTRIPLES formatting not supported yet");
8989
}
9090

91-
private String formatTrig(String rawUnix, File file) {
91+
private String formatTrig(File file) {
9292
throw new UnsupportedOperationException("TRIG formatting not supported yet");
9393
}
9494

0 commit comments

Comments
 (0)