Skip to content

Commit da00d3a

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

File tree

69 files changed

+500
-226
lines changed

Some content is hidden

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

69 files changed

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

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,64 +98,84 @@ private static class Buffer implements IBuffer {
9898
this.contents = contents;
9999
}
100100

101+
@Override
101102
public void addBufferChangedListener(IBufferChangedListener listener) {}
102103

104+
@Override
103105
public void append(char[] text) {}
104106

107+
@Override
105108
public void append(String text) {}
106109

110+
@Override
107111
public void close() {}
108112

113+
@Override
109114
public char getChar(int position) {
110115
return '\u0000';
111116
}
112117

118+
@Override
113119
public char[] getCharacters() {
114120
return contents.toCharArray();
115121
}
116122

123+
@Override
117124
public String getContents() {
118125
return contents;
119126
}
120127

128+
@Override
121129
public int getLength() {
122130
return 0;
123131
}
124132

133+
@Override
125134
public IOpenable getOwner() {
126135
return null;
127136
}
128137

138+
@Override
129139
public String getText(int offset, int length) {
130140
return null;
131141
}
132142

143+
@Override
133144
public IResource getUnderlyingResource() {
134145
return null;
135146
}
136147

148+
@Override
137149
public boolean hasUnsavedChanges() {
138150
return false;
139151
}
140152

153+
@Override
141154
public boolean isClosed() {
142155
return false;
143156
}
144157

158+
@Override
145159
public boolean isReadOnly() {
146160
return true;
147161
}
148162

163+
@Override
149164
public void removeBufferChangedListener(IBufferChangedListener listener) {}
150165

166+
@Override
151167
public void replace(int position, int length, char[] text) {}
152168

169+
@Override
153170
public void replace(int position, int length, String text) {}
154171

172+
@Override
155173
public void save(IProgressMonitor progress, boolean force) {}
156174

175+
@Override
157176
public void setContents(char[] contents) {}
158177

178+
@Override
159179
public void setContents(String contents) {
160180
this.contents = contents;
161181
}

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/src/compatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0Adapter.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.
@@ -115,7 +115,7 @@ public String format(
115115
private static EditorConfigOverride createEditorConfigOverride(final List<Rule> rules, Map<String, Object> editorConfigOverrideMap) {
116116
// Get properties from rules in the rule sets
117117
Stream<EditorConfigProperty<?>> ruleProperties = rules.stream()
118-
.filter(rule -> rule instanceof UsesEditorConfigProperties)
118+
.filter(UsesEditorConfigProperties.class::isInstance)
119119
.flatMap(rule -> ((UsesEditorConfigProperties) rule).getEditorConfigProperties().stream());
120120

121121
// Create a mapping of properties to their names based on rule properties and default properties

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

0 commit comments

Comments
 (0)