Skip to content

Commit 7433670

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech featuring StaticImport
1 parent 90ff85a commit 7433670

File tree

236 files changed

+1590
-1120
lines changed

Some content is hidden

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

236 files changed

+1590
-1120
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: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
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+
}
10+
11+
tasks.withType(JavaCompile).configureEach {
12+
options.errorprone {
13+
allErrorsAsWarnings = true // build will break until complain.
14+
disableWarningsInGeneratedCode = true
15+
disable(
16+
'DefaultCharset', // contract on ByteArrayOutputStream suggest default encoding.
17+
// bug
18+
'AddNullMarkedToPackageInfo',
19+
'Slf4jLogStatement',
20+
)
21+
error(
22+
'EmptyMethod',
23+
'EmptyMonoZip',
24+
'LexicographicalAnnotationAttributeListing',
25+
'LexicographicalAnnotationListing',
26+
'MissingOverride',
27+
'MissingSuperCall',
28+
'MissingTestCall',
29+
'NonEmptyMono',
30+
'OptionalMapUnusedValue',
31+
'OptionalOfRedundantMethod',
32+
'RedundantSetterCall',
33+
'RedundantStringConversion',
34+
'RedundantStringEscape',
35+
'StaticImport',
36+
'StringJoin',
37+
'UnnecessaryCheckNotNull',
38+
'UnnecessaryTypeArgument',
39+
'UnusedAnonymousClass',
40+
'UnusedCollectionModifiedInPlace',
41+
)
42+
errorproneArgs.add('-XepOpt:Refaster:NamePattern=^(?!.*Rules\\$).*') // might consider.
43+
// dev opt-in
44+
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
45+
// apply
46+
errorproneArgs.addAll(
47+
'-XepPatchLocation:IN_PLACE',
48+
'-XepPatchChecks:' +
49+
'StaticImport,' +
50+
'EmptyMethod,' +
51+
'EmptyMonoZip,' +
52+
'LexicographicalAnnotationAttributeListing,' +
53+
'LexicographicalAnnotationListing,' +
54+
'MissingOverride,' +
55+
'MissingSuperCall,' +
56+
'MissingTestCall,' +
57+
'NonEmptyMono,' +
58+
'OptionalMapUnusedValue,' +
59+
'OptionalOfRedundantMethod,' +
60+
'RedundantSetterCall,' +
61+
'RedundantStringConversion,' +
62+
'RedundantStringEscape,' +
63+
'StringJoin,' +
64+
'UnnecessaryCheckNotNull,' +
65+
'UnnecessaryTypeArgument,' +
66+
'UnusedAnonymousClass,' +
67+
'UnusedCollectionModifiedInPlace,'
68+
// 'AddNullMarkedToPackageInfo,' +
69+
// 'AlwaysThrows,' +
70+
// 'AmbiguousJsonCreator,' +
71+
// 'AndroidInjectionBeforeSuper,' +
72+
// 'ArrayEquals,' +
73+
// 'ArrayFillIncompatibleType,' +
74+
// 'ArrayHashCode,' +
75+
// 'ArrayToString,' +
76+
// 'ArraysAsListPrimitiveArray,' +
77+
// 'AssertJNullnessAssertion,' +
78+
// 'AsyncCallableReturnsNull,' +
79+
// 'AsyncFunctionReturnsNull,' +
80+
// 'AutoValueBuilderDefaultsInConstructor,' +
81+
// 'AutoValueConstructorOrderChecker,' +
82+
// 'AutowiredConstructor,' +
83+
// 'BadAnnotationImplementation,' +
84+
// 'BadShiftAmount,' +
85+
// 'BanJNDI,' +
86+
// 'BoxedPrimitiveEquality,' +
87+
// 'BundleDeserializationCast,' +
88+
// 'CanonicalAnnotationSyntax,' +
89+
// 'CanonicalClassNameUsage,' +
90+
// 'ChainingConstructorIgnoresParameter,' +
91+
// 'CheckNotNullMultipleTimes,' +
92+
// 'CheckReturnValue,' +
93+
// 'ClassCastLambdaUsage,' +
94+
// 'CollectionIncompatibleType,' +
95+
// 'CollectionToArraySafeParameter,' +
96+
// 'CollectorMutability,' +
97+
// 'ComparableType,' +
98+
// 'ComparingThisWithNull,' +
99+
// 'ComparisonOutOfRange,' +
100+
// 'CompatibleWithAnnotationMisuse,' +
101+
// 'CompileTimeConstant,' +
102+
// 'ComputeIfAbsentAmbiguousReference,' +
103+
// 'ConditionalExpressionNumericPromotion,' +
104+
// 'ConstantNaming,' +
105+
// 'ConstantOverflow,' +
106+
// 'DaggerProvidesNull,' +
107+
// 'DangerousLiteralNull,' +
108+
// 'DeadException,' +
109+
// 'DeadThread,' +
110+
// 'DereferenceWithNullBranch,' +
111+
// 'DirectReturn,' +
112+
// 'DiscardedPostfixExpression,' +
113+
// 'DoNotCall,' +
114+
// 'DoNotMock,' +
115+
// 'DoubleBraceInitialization,' +
116+
// 'DuplicateMapKeys,' +
117+
// 'DurationFrom,' +
118+
// 'DurationGetTemporalUnit,' +
119+
// 'DurationTemporalUnit,' +
120+
// 'DurationToLongTimeUnit,' +
121+
// 'EagerStringFormatting,' +
122+
// 'EqualsHashCode,' +
123+
// 'EqualsNaN,' +
124+
// 'EqualsNull,' +
125+
// 'EqualsReference,' +
126+
// 'EqualsWrongThing,' +
127+
// 'ExplicitArgumentEnumeration,' +
128+
// 'ExplicitEnumOrdering,' +
129+
// 'FloggerFormatString,' +
130+
// 'FloggerLogString,' +
131+
// 'FloggerLogVarargs,' +
132+
// 'FloggerSplitLogStatement,' +
133+
// 'FluxFlatMapUsage,' +
134+
// 'FluxImplicitBlock,' +
135+
// 'ForOverride,' +
136+
// 'FormatString,' +
137+
// 'FormatStringAnnotation,' +
138+
// 'FormatStringConcatenation,' +
139+
// 'FromTemporalAccessor,' +
140+
// 'FunctionalInterfaceMethodChanged,' +
141+
// 'FunctionalInterfaceMethodChanged,' +
142+
// 'FuturesGetCheckedIllegalExceptionType,' +
143+
// 'FuzzyEqualsShouldNotBeUsedInEqualsMethod,' +
144+
// 'GetClassOnAnnotation,' +
145+
// 'GetClassOnClass,' +
146+
// 'GuardedBy,' +
147+
// 'GuiceAssistedInjectScoping,' +
148+
// 'GuiceAssistedParameters,' +
149+
// 'GuiceInjectOnFinalField,' +
150+
// 'HashtableContains,' +
151+
// 'IdentityBinaryExpression,' +
152+
// 'IdentityConversion,' +
153+
// 'IdentityHashMapBoxing,' +
154+
// 'Immutable,' +
155+
// 'ImmutableEnumChecker,' +
156+
// 'ImmutablesSortedSetComparator,' +
157+
// 'ImpossibleNullComparison,' +
158+
// 'Incomparable,' +
159+
// 'IncompatibleArgumentType,' +
160+
// 'IncompatibleModifiers,' +
161+
// 'IndexOfChar,' +
162+
// 'InexactVarargsConditional,' +
163+
// 'InfiniteRecursion,' +
164+
// 'InjectMoreThanOneScopeAnnotationOnClass,' +
165+
// 'InjectOnMemberAndConstructor,' +
166+
// 'InlineMeValidator,' +
167+
// 'InstantTemporalUnit,' +
168+
// 'InvalidJavaTimeConstant,' +
169+
// 'InvalidPatternSyntax,' +
170+
// 'InvalidTimeZoneID,' +
171+
// 'InvalidZoneId,' +
172+
// 'IsInstanceIncompatibleType,' +
173+
// 'IsInstanceLambdaUsage,' +
174+
// 'IsInstanceOfClass,' +
175+
// 'IsLoggableTagLength,' +
176+
// 'JUnit3TestNotRun,' +
177+
// 'JUnit4ClassAnnotationNonStatic,' +
178+
// 'JUnit4SetUpNotRun,' +
179+
// 'JUnit4TearDownNotRun,' +
180+
// 'JUnit4TestNotRun,' +
181+
// 'JUnit4TestsNotRunWithinEnclosed,' +
182+
// 'JUnitAssertSameCheck,' +
183+
// 'JUnitClassModifiers,' +
184+
// 'JUnitMethodDeclaration,' +
185+
// 'JUnitNullaryParameterizedTestDeclaration,' +
186+
// 'JUnitParameterMethodNotFound,' +
187+
// 'JUnitValueSource,' +
188+
// 'JavaxInjectOnAbstractMethod,' +
189+
// 'JodaToSelf,' +
190+
// 'LenientFormatStringValidation,' +
191+
// 'LiteByteStringUtf8,' +
192+
// 'LocalDateTemporalAmount,' +
193+
// 'LockOnBoxedPrimitive,' +
194+
// 'LoopConditionChecker,' +
195+
// 'LossyPrimitiveCompare,' +
196+
// 'MathRoundIntLong,' +
197+
// 'MislabeledAndroidString,' +
198+
// 'MisleadingEmptyVarargs,' +
199+
// 'MisleadingEscapedSpace,' +
200+
// 'MisplacedScopeAnnotations,' +
201+
// 'MisusedDayOfYear,' +
202+
// 'MisusedWeekYear,' +
203+
// 'MixedDescriptors,' +
204+
// 'MockitoMockClassReference,' +
205+
// 'MockitoStubbing,' +
206+
// 'MockitoUsage,' +
207+
// 'ModifyingCollectionWithItself,' +
208+
// 'MongoDBTextFilterUsage,' +
209+
// 'MoreThanOneInjectableConstructor,' +
210+
// 'MustBeClosedChecker,' +
211+
// 'NCopiesOfChar,' +
212+
// 'NestedOptionals,' +
213+
// 'NestedPublishers,' +
214+
// 'NoCanIgnoreReturnValueOnClasses,' +
215+
// 'NonCanonicalStaticImport,' +
216+
// 'NonFinalCompileTimeConstant,' +
217+
// 'NonRuntimeAnnotation,' +
218+
// 'NonStaticImport,' +
219+
// 'NullArgumentForNonNullParameter,' +
220+
// 'NullTernary,' +
221+
// 'NullableOnContainingClass,' +
222+
// 'OptionalEquality,' +
223+
// 'OptionalOrElseGet,' +
224+
// 'OverlappingQualifierAndScopeAnnotation,' +
225+
// 'OverridesJavaxInjectableMethod,' +
226+
// 'PackageInfo,' +
227+
// 'ParametersButNotParameterized,' +
228+
// 'ParcelableCreator,' +
229+
// 'PeriodFrom,' +
230+
// 'PeriodGetTemporalUnit,' +
231+
// 'PeriodTimeMath,' +
232+
// 'PreconditionsInvalidPlaceholder,' +
233+
// 'PrimitiveComparison,' +
234+
// 'PrivateSecurityContractProtoAccess,' +
235+
// 'ProtoBuilderReturnValueIgnored,' +
236+
// 'ProtoStringFieldReferenceEquality,' +
237+
// 'ProtoTruthMixedDescriptors,' +
238+
// 'ProtocolBufferOrdinal,' +
239+
// 'ProvidesMethodOutsideOfModule,' +
240+
// 'RandomCast,' +
241+
// 'RandomModInteger,' +
242+
// 'RectIntersectReturnValueIgnored,' +
243+
// 'RefasterAnyOfUsage,' +
244+
// 'RequestMappingAnnotation,' +
245+
// 'RequestParamType,' +
246+
// 'RequiredModifiers,' +
247+
// 'RestrictedApi,' +
248+
// 'ReturnValueIgnored,' +
249+
// 'SelfAssertion,' +
250+
// 'SelfAssignment,' +
251+
// 'SelfComparison,' +
252+
// 'SelfEquals,' +
253+
// 'SetUnrecognized,' +
254+
// 'ShouldHaveEvenArgs,' +
255+
// 'SizeGreaterThanOrEqualsZero,' +
256+
// 'Slf4jLogStatement,' +
257+
// 'Slf4jLoggerDeclarationSlf4jLoggerDeclaration,' +
258+
// 'SpringMvcAnnotation,' +
259+
// 'StreamToString,' +
260+
// 'StringBuilderInitWithChar,' +
261+
// 'SubstringOfZero,' +
262+
// 'SuppressWarningsDeprecated,' +
263+
// 'TemporalAccessorGetChronoField,' +
264+
// 'TestParametersNotInitialized,' +
265+
// 'TheoryButNoTheories,' +
266+
// 'ThreadBuilderNameWithPlaceholder,' +
267+
// 'ThrowIfUncheckedKnownChecked,' +
268+
// 'ThrowNull,' +
269+
// 'TimeZoneUsage,' +
270+
// 'TreeToString,' +
271+
// 'TryFailThrowable,' +
272+
// 'TypeParameterQualifier,' +
273+
// 'UnicodeDirectionalityCharacters,' +
274+
// 'UnicodeInCode,' +
275+
// 'UnsafeWildcard,' +
276+
// 'VarTypeName,' +
277+
// 'WrongOneof,' +
278+
// 'XorPower,' +
279+
// 'ZoneIdOfZ,'
280+
)
281+
}
282+
}
283+
}

lib-extra/src/cdt/java/com/diffplug/spotless/extra/glue/cdt/EclipseCdtFormatterStepImpl.java

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

18+
import static java.util.stream.Collectors.toMap;
19+
1820
import java.util.Map;
1921
import java.util.Map.Entry;
2022
import java.util.Properties;
21-
import java.util.stream.Collectors;
2223
import java.util.stream.Stream;
2324

2425
import org.eclipse.cdt.core.formatter.CodeFormatter;
@@ -32,7 +33,7 @@ public class EclipseCdtFormatterStepImpl {
3233

3334
public EclipseCdtFormatterStepImpl(Properties settings) throws Exception {
3435
Stream<Entry<Object, Object>> stream = settings.entrySet().stream();
35-
Map<String, String> settingsMap = stream.collect(Collectors.toMap(
36+
Map<String, String> settingsMap = stream.collect(toMap(
3637
e -> String.valueOf(e.getKey()),
3738
e -> String.valueOf(e.getValue())));
3839
codeFormatter = org.eclipse.cdt.core.ToolFactory.createDefaultCodeFormatter(settingsMap);

lib-extra/src/groovy/java/com/diffplug/spotless/extra/glue/groovy/GrEclipseFormatterStepImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
*/
1616
package com.diffplug.spotless.extra.glue.groovy;
1717

18+
import static java.util.Collections.synchronizedList;
19+
1820
import java.io.ByteArrayInputStream;
1921
import java.io.ByteArrayOutputStream;
2022
import java.io.IOException;
2123
import java.nio.file.Files;
2224
import java.util.ArrayList;
23-
import java.util.Collections;
2425
import java.util.List;
2526
import java.util.Map;
2627
import java.util.Properties;
@@ -111,7 +112,7 @@ public GroovyErrorListener() {
111112
* We need a synchronized list here, in case multiple instantiations
112113
* run in parallel.
113114
*/
114-
errors = Collections.synchronizedList(new ArrayList<>());
115+
errors = synchronizedList(new ArrayList<>());
115116
ILog groovyLogger = GroovyCoreActivator.getDefault().getLog();
116117
groovyLogger.addLogListener(this);
117118
synchronized (GroovyLogManager.manager) {

lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/EclipseJdtFormatterStepImpl.java

Lines changed: 4 additions & 3 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.
@@ -15,11 +15,12 @@
1515
*/
1616
package com.diffplug.spotless.extra.glue.jdt;
1717

18+
import static java.util.stream.Collectors.toMap;
19+
1820
import java.io.File;
1921
import java.util.HashMap;
2022
import java.util.Map;
2123
import java.util.Properties;
22-
import java.util.stream.Collectors;
2324

2425
import org.eclipse.jdt.core.formatter.CodeFormatter;
2526
import org.eclipse.jdt.internal.compiler.env.IModule;
@@ -37,7 +38,7 @@ public class EclipseJdtFormatterStepImpl {
3738
private final EclipseJdtSortMembers.SortProperties sortProperties;
3839

3940
public EclipseJdtFormatterStepImpl(Properties formatterSettings, Map<String, String> sortProperties) {
40-
Map<String, String> options = formatterSettings.entrySet().stream().collect(Collectors.toMap(
41+
Map<String, String> options = formatterSettings.entrySet().stream().collect(toMap(
4142
e -> String.valueOf(e.getKey()),
4243
e -> String.valueOf(e.getValue()),
4344
(prev, next) -> next,

0 commit comments

Comments
 (0)