@@ -9,6 +9,7 @@ dependencies {
99}
1010
1111val disableErrorProne = properties[" disableErrorProne" ]?.toString()?.toBoolean() ? : false
12+ val testLatestDeps = gradle.startParameter.projectProperties[" testLatestDeps" ] == " true"
1213
1314tasks {
1415 withType<JavaCompile >().configureEach {
@@ -22,57 +23,125 @@ tasks {
2223 disableWarningsInGeneratedCode.set(true )
2324 allDisabledChecksAsWarnings.set(true )
2425
25- excludedPaths.set(" .*/build/generated/.*" )
26+ // Ignore warnings for generated and vendored classes
27+ excludedPaths.set(" .*/build/generated/.*|.*/concurrentlinkedhashmap/.*" )
2628
27- if (System .getenv(" CI" ) == null ) {
28- disable(" SystemOut" )
29- }
30-
31- // Still Java 8
32- disable(" Varifier" )
29+ // it's very convenient to debug stuff in the javaagent using System.out.println
30+ // and we don't want to conditionally only check this in CI
31+ // because then the remote gradle cache won't work for local builds
32+ // so we check this via checkstyle instead
33+ disable(" SystemOut" )
3334
34- // Intellij does a nice job of displaying parameter names
3535 disable(" BooleanParameter" )
3636
37- // Needed for legacy 2.x bridge
38- disable(" JavaUtilDate" )
37+ // We often override a method returning Iterable which this makes tedious
38+ // for questionable value.
39+ disable(" PreferredInterfaceType" )
3940
4041 // Doesn't work well with Java 8
4142 disable(" FutureReturnValueIgnored" )
4243
43- // Needs Java 9+
44- disable(" JavaDurationGetSecondsToToSeconds" )
44+ // Still Java 8
45+ disable(" Varifier" )
46+
47+ // Doesn't currently use Var annotations.
48+ disable(" Var" ) // "-Xep:Var:OFF"
49+
50+ // ImmutableRefactoring suggests using com.google.errorprone.annotations.Immutable,
51+ // but currently uses javax.annotation.concurrent.Immutable
52+ disable(" ImmutableRefactoring" )
4553
46- // Require Guava
54+ // AutoValueImmutableFields suggests returning Guava types from API methods
4755 disable(" AutoValueImmutableFields" )
48- disable( " StringSplitter " )
56+ // Suggests using Guava types for fields but we don't use Guava
4957 disable(" ImmutableMemberCollection" )
5058
51- // Don't currently use this (to indicate a local variable that's mutated) but could
52- // consider for future .
53- disable(" Var " )
59+ // Fully qualified names may be necessary when deprecating a class to avoid
60+ // deprecation warning .
61+ disable(" UnnecessarilyFullyQualified " )
5462
55- // Don't support Android without desugar
63+ // TODO (trask) use animal sniffer
64+ disable(" Java8ApiChecker" )
5665 disable(" AndroidJdkLibsChecker" )
66+
67+ // apparently disabling android doesn't disable this
5768 disable(" StaticOrDefaultInterfaceMethod" )
5869
59- // needed temporarily while hosting azure-monitor-opentelemetry-exporter in this repo
60- disable(" MissingSummary" )
61- disable(" UnnecessaryDefaultInEnumSwitch" )
62- disable(" InconsistentOverloads" )
70+ // We don't depend on Guava so use normal splitting
71+ disable(" StringSplitter" )
72+
73+ // Prevents lazy initialization
74+ disable(" InitializeInline" )
75+
76+ // Seems to trigger even when a deprecated method isn't called anywhere.
77+ // We don't get much benefit from it anyways.
78+ disable(" InlineMeSuggester" )
79+
80+ disable(" DoNotCallSuggester" )
81+
82+ // We have nullaway so don't need errorprone nullable checks which have more false positives.
83+ disable(" FieldMissingNullable" )
84+ disable(" ParameterMissingNullable" )
85+ disable(" ReturnMissingNullable" )
86+ disable(" VoidMissingNullable" )
87+
88+ // allow UPPERCASE type parameter names
89+ disable(" TypeParameterNaming" )
90+
91+ // In bytecode instrumentation it's very common to separate across onEnter / onExit
92+ // TODO: Only disable for javaagent instrumentation modules.
93+ disable(" MustBeClosedChecker" )
94+
95+ // Common to avoid an allocation. Revisit if it's worth opt-in suppressing instead of
96+ // disabling entirely.
97+ disable(" MixedMutabilityReturnType" )
98+
99+ // We end up using obsolete types if a library we're instrumenting uses them.
100+ disable(" JdkObsolete" )
101+ disable(" JavaUtilDate" )
102+
103+ // TODO: Remove this, we use this pattern in several tests and it will mean some moving.
104+ disable(" DefaultPackage" )
105+
106+ // We don't have custom checks like OpenTelemetry, so disable the standard utility class check
107+ disable(" PrivateConstructorForUtilityClass" )
63108
64109 disable(" CanIgnoreReturnValueSuggester" )
65110
66- disable(" NonFinalStaticField" )
111+ // TODO: Remove this, probably after instrumenter API migration instead of dealing with
112+ // older APIs.
113+ disable(" InconsistentOverloads" )
114+
115+ // lots of low level APIs use arrays
116+ disable(" AvoidObjectArrays" )
117+
118+ disable(" BanClassLoader" )
67119
68120 // YodaConditions may improve safety in some cases. The argument of increased
69121 // cognitive load is dubious.
70122 disable(" YodaCondition" )
71123
124+ disable(" NonFinalStaticField" )
125+
72126 // Requires adding compile dependency to JSpecify
73127 disable(" AddNullMarkedToPackageInfo" )
74128
75- if (name.contains(" Jmh" )) {
129+ // needed temporarily while hosting azure-monitor-opentelemetry-exporter in this repo
130+ disable(" MissingSummary" )
131+ disable(" UnnecessaryDefaultInEnumSwitch" )
132+
133+ // Needs Java 9+
134+ disable(" JavaDurationGetSecondsToToSeconds" )
135+
136+ if (testLatestDeps) {
137+ // Some latest dep tests are compiled for java 17 although the base version uses an older
138+ // version. Disable rules that suggest using new language features.
139+ disable(" StatementSwitchToExpressionSwitch" )
140+ disable(" PatternMatchingInstanceof" )
141+ }
142+
143+ if (name.contains(" Jmh" ) || name.contains(" Test" )) {
144+ // Allow underscore in test-type method names
76145 disable(" MemberName" )
77146 }
78147 }
0 commit comments