Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions gradle/error-prone.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ tasks.withType(JavaCompile).configureEach {
'NonStaticImport',
'Slf4jLoggerDeclaration', // logger -> log
'StaticImport',
// critical, finds lots of bugs... unused configs and stuff.
'Unused',
'UnusedMethod',
'UnusedParameters',
'UnusedVariable',
)
error(
'AmbiguousJsonCreator',
Expand All @@ -52,11 +47,19 @@ tasks.withType(JavaCompile).configureEach {
'SelfAssignment',
'StringJoin',
'StringJoining',
'Unused',
'UnusedMethod',
'UnusedParameters',
'UnusedVariable'
)
// 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|.*/EclipseJdtFormatterStepTeeeest.java|.*/JvmTest.java')
errorproneArgs.add('-XepExcludedPaths:.*/SelfTest.java')
// bug https://github.com/google/error-prone/issues/5289
errorproneArgs.add('-XepExcludedPaths:.*/EclipseJdtFormatterStepTest.java')
errorproneArgs.add('-XepExcludedPaths:.*/JvmTest.java')
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
errorproneArgs.addAll(
'-XepPatchLocation:IN_PLACE',
Expand Down Expand Up @@ -86,7 +89,10 @@ tasks.withType(JavaCompile).configureEach {
'Slf4jLogStatement,' +
'StringJoin,' +
'StringJoining,' +
'TimeZoneUsage,'
'TimeZoneUsage,' +
'UnusedMethod,' +
'UnusedParameters,' +
'UnusedVariable,'
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.diffplug.spotless.extra.cpp;

import java.util.stream.Stream;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand All @@ -36,7 +34,4 @@ void formatWithVersion(String version) throws Exception {
"#include <a.h>;\nint main(int argc, char *argv[]) {\n}\n");
}

private static Stream<String> formatWithVersion() {
return Stream.of("11.0", "11.6", EclipseCdtFormatterStep.defaultVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
*/
package com.diffplug.spotless.extra.groovy;

import java.util.stream.Stream;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import com.diffplug.spotless.TestProvisioner;
import com.diffplug.spotless.extra.eclipse.EquoResourceHarness;

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

public GrEclipseFormatterStepTest() {
super(GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral()));
Expand All @@ -38,7 +34,4 @@ void formatWithVersion(String version) throws Exception {
"class F{ def m(){} }", "class F{\n\tdef m(){}\n}");
}

private static Stream<String> formatWithVersion() {
return Stream.of("4.18", GrEclipseFormatterStep.defaultVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.nio.file.Files;
import java.util.Properties;
import java.util.function.Consumer;
import java.util.stream.Stream;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -52,10 +51,6 @@ void formatWithVersion(String version) throws Exception {
harnessFor(version).test("someFilename", unformatted, formatted);
}

private static Stream<String> formatWithVersion() {
return Stream.of(JVM_SUPPORT.getRecommendedFormatterVersion(), EclipseWtpFormatterStep.defaultVersion());
}

/**
* Check that configuration change is supported by all WTP formatters.
* Some of the formatters only support static workspace configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
import com.pinterest.ktlint.rule.engine.api.Code;
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
Expand All @@ -55,8 +52,6 @@

public class KtLintCompat0Dot49Dot0Adapter implements KtLintCompatAdapter {

private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot49Dot0Adapter.class);

private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
import com.pinterest.ktlint.rule.engine.api.Code;
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
Expand Down Expand Up @@ -55,8 +52,6 @@

public class KtLintCompat0Dot50Dot0Adapter implements KtLintCompatAdapter {

private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot50Dot0Adapter.class);

private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3;
import com.pinterest.ktlint.rule.engine.api.Code;
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults;
Expand Down Expand Up @@ -54,8 +51,6 @@

public class KtLintCompat1Dot0Dot0Adapter implements KtLintCompatAdapter {

private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat1Dot0Dot0Adapter.class);

private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

static {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 DiffPlug
* Copyright 2023-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,6 @@
*/
package com.diffplug.spotless.glue.gherkin;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.diffplug.spotless.FormatterFunc;
import com.diffplug.spotless.gherkin.GherkinUtilsConfig;

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

public class GherkinUtilsFormatterFunc implements FormatterFunc {
private static final Logger LOGGER = LoggerFactory.getLogger(GherkinUtilsFormatterFunc.class);

private final GherkinUtilsConfig gherkinSimpleConfig;

public GherkinUtilsFormatterFunc(GherkinUtilsConfig gherkinSimpleConfig) {
this.gherkinSimpleConfig = gherkinSimpleConfig;

}

// Follows https://github.com/cucumber/gherkin-utils/blob/main/java/src/test/java/io/cucumber/gherkin/utils/pretty/PrettyTest.java
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 DiffPlug
* Copyright 2023-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,6 @@
*/
package com.diffplug.spotless.glue.java;

import java.util.Objects;

import javax.annotation.Nonnull;

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

public class GoogleJavaFormatRemoveUnusedImporterFormatterFunc implements FormatterFunc {

@Nonnull
private final String version;

public GoogleJavaFormatRemoveUnusedImporterFormatterFunc(@Nonnull String version) {
this.version = Objects.requireNonNull(version);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static FormatterStep lint(String name, String regex, String lintDetail) {
Objects.requireNonNull(regex, "regex");
Objects.requireNonNull(lintDetail, "lintDetail");
return FormatterStep.createLazy(name,
() -> new LintState(Pattern.compile(regex, Pattern.UNIX_LINES | Pattern.MULTILINE), name, lintDetail),
() -> new LintState(Pattern.compile(regex, Pattern.UNIX_LINES | Pattern.MULTILINE), lintDetail),
LintState::toLinter);
}

Expand All @@ -68,12 +68,12 @@ private static final class LintState implements Serializable {
private static final long serialVersionUID = 1L;

private final Pattern regex;
private final String ruleId;

private final String lintDetail;

LintState(Pattern regex, String ruleId, String lintDetail) {
LintState(Pattern regex, String lintDetail) {
this.regex = regex;
this.ruleId = ruleId;

this.lintDetail = lintDetail;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ public final class PalantirJavaFormatStep implements Serializable {
private final JarState.Promised jarState;
/** Version of the formatter jar. */
private final String formatterVersion;
private final String style;

/** Whether to format Java docs. */
private final boolean formatJavadoc;

private PalantirJavaFormatStep(JarState.Promised jarState,
String formatterVersion,
String style,
boolean formatJavadoc) {
this.jarState = jarState;
this.formatterVersion = formatterVersion;
this.style = style;

this.formatJavadoc = formatJavadoc;
}

Expand All @@ -76,13 +75,12 @@ public static FormatterStep create(String version, String style, Provisioner pro
* Creates a step which formats everything - code, import order, unused imports, and Java docs. And with the given
* format style.
*/
public static FormatterStep create(String version, String style, boolean formatJavadoc, Provisioner provisioner) {
public static FormatterStep create(String version, String ignored, boolean formatJavadoc, Provisioner provisioner) {
Objects.requireNonNull(version, "version");
Objects.requireNonNull(style, "style");
Objects.requireNonNull(provisioner, "provisioner");

return FormatterStep.create(NAME,
new PalantirJavaFormatStep(JarState.promise(() -> JarState.from(MAVEN_COORDINATE + version, provisioner)), version, style, formatJavadoc),
new PalantirJavaFormatStep(JarState.promise(() -> JarState.from(MAVEN_COORDINATE + version, provisioner)), version, formatJavadoc),
PalantirJavaFormatStep::equalityState,
State::createFormat);
}
Expand All @@ -103,22 +101,22 @@ public static boolean defaultFormatJavadoc() {
}

private State equalityState() {
return new State(jarState.get(), formatterVersion, style, formatJavadoc);
return new State(jarState.get(), formatterVersion, formatJavadoc);
}

private static final class State implements Serializable {
@Serial
private static final long serialVersionUID = 1L;

private final JarState jarState;
private final String formatterVersion;

private final String style;
private final boolean formatJavadoc;

State(JarState jarState, String formatterVersion, String style, boolean formatJavadoc) {
State(JarState jarState, String style, boolean formatJavadoc) {
ModuleHelper.doOpenInternalPackagesIfRequired();
this.jarState = jarState;
this.formatterVersion = formatterVersion;

this.style = style;
this.formatJavadoc = formatJavadoc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,15 @@ abstract class NpmFormatterStepStateBase implements Serializable {

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

private static final TimedLogger TIMED_LOGGER = TimedLogger.forLogger(LOGGER);

@Serial
private static final long serialVersionUID = 1460749955865959948L;

private final String stepName;
private final NpmConfig npmConfig;

public final NpmFormatterStepLocations locations;

protected NpmFormatterStepStateBase(String stepName, NpmConfig npmConfig, NpmFormatterStepLocations locations) throws IOException {
this.stepName = requireNonNull(stepName);

this.npmConfig = requireNonNull(npmConfig);
this.locations = locations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public String apply(String rawUnix, File file) throws Exception {
return formatTurtle(rawUnix, file, reflectionHelper);
}
if (TRIG_EXTENSIONS.contains(extension)) {
return formatTrig(rawUnix, file);
return formatTrig();
}
if (NTRIPLES_EXTENSIONS.contains(extension)) {
return formatNTriples(rawUnix, file);
return formatNTriples();
}
if (NQUADS_EXTENSIONS.contains(extension)) {
return formatNQuads(rawUnix, file);
return formatNQuads();
}
throw new IllegalArgumentException("Cannot handle file with extension %s".formatted(extension));
} catch (InvocationTargetException e) {
Expand All @@ -80,15 +80,15 @@ public String apply(String rawUnix, File file) throws Exception {
}
}

private String formatNQuads(String rawUnix, File file) {
private String formatNQuads() {
throw new UnsupportedOperationException("NQUADS formatting not supported yet");
}

private String formatNTriples(String rawUnix, File file) {
private String formatNTriples() {
throw new UnsupportedOperationException("NTRIPLES formatting not supported yet");
}

private String formatTrig(String rawUnix, File file) {
private String formatTrig() {
throw new UnsupportedOperationException("TRIG formatting not supported yet");
}

Expand Down
Loading
Loading