Skip to content

Commit 0e2141a

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech featuring ConstantNaming
1 parent 90ff85a commit 0e2141a

File tree

87 files changed

+382
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+382
-310
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repositories {
1212
apply from: rootProject.file('gradle/java-publish.gradle')
1313
apply from: rootProject.file('gradle/changelog.gradle')
1414
allprojects {
15+
apply from: rootProject.file('gradle/error-prone.gradle')
1516
apply from: rootProject.file('gradle/rewrite.gradle')
1617
apply from: rootProject.file('gradle/spotless.gradle')
1718
}

gradle/error-prone.gradle

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import static java.lang.System.getenv
2+
3+
apply plugin: 'net.ltgt.errorprone'
4+
5+
dependencies {
6+
errorprone('com.google.errorprone:error_prone_core:2.42.0')
7+
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.25.0')
8+
errorprone('tech.picnic.error-prone-support:refaster-runner:0.25.0')
9+
constraints {
10+
errorprone('com.google.guava:guava') {
11+
version {
12+
require('33.4.8-jre')
13+
}
14+
because('Older versions use deprecated methods in sun.misc.Unsafe')
15+
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
16+
}
17+
}
18+
}
19+
20+
tasks.withType(JavaCompile).configureEach {
21+
options.errorprone {
22+
allErrorsAsWarnings = true // ModuleHelper.java:37: warning: Unsafe is internal proprietary API and may be removed in a future release
23+
disableWarningsInGeneratedCode = true
24+
error(
25+
'ConstantNaming',
26+
'DirectReturn',
27+
'EmptyMethod',
28+
'EmptyMonoZip',
29+
'LexicographicalAnnotationAttributeListing',
30+
'LexicographicalAnnotationListing',
31+
'MissingTestCall',
32+
'NonEmptyMono',
33+
'NonStaticImport',
34+
'OptionalMapUnusedValue',
35+
'OptionalOfRedundantMethod',
36+
'RedundantSetterCall',
37+
'RedundantStringConversion',
38+
'RedundantStringEscape',
39+
'StringJoin',
40+
'UnnecessaryCheckNotNull',
41+
'UnnecessaryTypeArgument',
42+
'UnusedAnonymousClass',
43+
'UnusedCollectionModifiedInPlace',
44+
// 'MissingOverride',
45+
// 'StaticImport',
46+
)
47+
errorproneArgs.add('-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*')
48+
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
49+
errorproneArgs.addAll(
50+
'-XepPatchLocation:IN_PLACE',
51+
'-XepPatchChecks:' +
52+
'ConstantNaming,' +
53+
'DirectReturn,' +
54+
'EmptyMethod,' +
55+
'EmptyMonoZip,' +
56+
'LexicographicalAnnotationAttributeListing,' +
57+
'LexicographicalAnnotationListing,' +
58+
'MissingTestCall,' +
59+
'NonEmptyMono,' +
60+
'NonStaticImport,' +
61+
'OptionalMapUnusedValue,' +
62+
'OptionalOfRedundantMethod,' +
63+
'RedundantSetterCall,' +
64+
'RedundantStringConversion,' +
65+
'RedundantStringEscape,' +
66+
'StringJoin,' +
67+
'UnnecessaryCheckNotNull,' +
68+
'UnnecessaryTypeArgument,' +
69+
'UnusedAnonymousClass,' +
70+
'UnusedCollectionModifiedInPlace,'
71+
// 'MissingOverride,' +
72+
// 'StaticImport,' +
73+
)
74+
}
75+
}
76+
}

lib-extra/src/main/java/com/diffplug/spotless/extra/GitWorkarounds.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ private static IOException emptyFile(File commonDir) {
202202
return new IOException("Empty 'commondir' file: " + commonDir.getAbsolutePath());
203203
}
204204

205-
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
206205
@Override
206+
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
207207
public FileRepositoryBuilder readEnvironment(SystemReader sr) {
208208
super.readEnvironment(sr);
209209

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 DiffPlug
2+
* Copyright 2022-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.
@@ -52,8 +52,8 @@ void external() throws IOException, GitAPIException {
5252
Assertions.assertThat(repositorySpecificResolver.getGitDir()).isEqualTo(gitDir);
5353
}
5454

55-
@Nested
5655
@DisplayName("Worktrees")
56+
@Nested
5757
class Worktrees {
5858
private File project1Tree;
5959
private File project1GitDir;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public EclipseCdtFormatterStepTest() {
2828
super(EclipseCdtFormatterStep.createBuilder(TestProvisioner.mavenCentral()));
2929
}
3030

31-
@ParameterizedTest
3231
@MethodSource
32+
@ParameterizedTest
3333
void formatWithVersion(String version) throws Exception {
3434
harnessFor(version).test("main.c",
3535
"#include <a.h>;\nint main(int argc, \nchar *argv[]) {}",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public GrEclipseFormatterStepTest() {
3131
super(GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral()));
3232
}
3333

34-
@ParameterizedTest
3534
@MethodSource
35+
@ParameterizedTest
3636
void formatWithVersion(String version) throws Exception {
3737
harnessFor(version).test("test.groovy",
3838
"class F{ def m(){} }", "class F{\n\tdef m(){}\n}");

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

Lines changed: 2 additions & 2 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.
@@ -35,8 +35,8 @@ public EclipseJdtFormatterStepTest() {
3535
super(createBuilder());
3636
}
3737

38-
@ParameterizedTest
3938
@MethodSource
39+
@ParameterizedTest
4040
void formatWithVersion(String version) throws Exception {
4141
harnessFor(version).test("test.java",
4242
"package p; class C{}",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public NestedTests(String unformatted, String formatted, EclipseWtpFormatterStep
4646
this.formatted = formatted;
4747
}
4848

49-
@ParameterizedTest
5049
@MethodSource
50+
@ParameterizedTest
5151
void formatWithVersion(String version) throws Exception {
5252
harnessFor(version).test("someFilename", unformatted, formatted);
5353
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 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.
@@ -55,7 +55,7 @@
5555

5656
public class KtLintCompat0Dot49Dot0Adapter implements KtLintCompatAdapter {
5757

58-
private static final Logger logger = LoggerFactory.getLogger(KtLintCompat0Dot49Dot0Adapter.class);
58+
private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot49Dot0Adapter.class);
5959

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 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.
@@ -55,7 +55,7 @@
5555

5656
public class KtLintCompat0Dot50Dot0Adapter implements KtLintCompatAdapter {
5757

58-
private static final Logger logger = LoggerFactory.getLogger(KtLintCompat0Dot50Dot0Adapter.class);
58+
private static final Logger LOGGER = LoggerFactory.getLogger(KtLintCompat0Dot50Dot0Adapter.class);
5959

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

0 commit comments

Comments
 (0)