File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
check_api/src/main/java/com/google/errorprone
core/src/test/java/com/google/errorprone/scanner Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -224,12 +224,12 @@ static ErrorProneAnalyzer createAnalyzer(
224
224
.customRefactorer ()
225
225
.or (
226
226
() -> {
227
- ScannerSupplier toUse =
228
- ErrorPronePlugins .loadPlugins (scannerSupplier , context )
229
- .applyOverrides (epOptions );
227
+ ScannerSupplier toUse = ErrorPronePlugins .loadPlugins (scannerSupplier , context );
230
228
ImmutableSet <String > namedCheckers = epOptions .patchingOptions ().namedCheckers ();
231
229
if (!namedCheckers .isEmpty ()) {
232
230
toUse = toUse .filter (bci -> namedCheckers .contains (bci .canonicalName ()));
231
+ } else {
232
+ toUse = toUse .applyOverrides (epOptions );
233
233
}
234
234
return ErrorProneScannerTransformer .create (toUse .get ());
235
235
})
Original file line number Diff line number Diff line change @@ -95,6 +95,35 @@ public void suppressionAnnotationIgnoredWithOptions() {
95
95
.doTest ();
96
96
}
97
97
98
+ @ Test
99
+ public void dontRunPatchForDisabledChecks () {
100
+ compilationHelper
101
+ .addSourceLines (
102
+ "Test.java" ,
103
+ "import com.google.errorprone.scanner.ScannerTest.Foo;" ,
104
+ "class Test {" ,
105
+ " Foo foo;" ,
106
+ "}" )
107
+ .setArgs ("-XepPatchLocation:IN_PLACE" , "-XepPatchChecks:" , "-Xep:ShouldNotUseFoo:OFF" )
108
+ .doTest ();
109
+ }
110
+
111
+ @ Test
112
+ public void dontRunPatchUnlessRequested () {
113
+ compilationHelper
114
+ .addSourceLines (
115
+ "Test.java" ,
116
+ "import com.google.errorprone.scanner.ScannerTest.Foo;" ,
117
+ "class Test {" ,
118
+ " Foo foo;" ,
119
+ "}" )
120
+ .setArgs (
121
+ "-XepPatchLocation:IN_PLACE" ,
122
+ "-Xep:ShouldNotUseFoo:WARN" ,
123
+ "-XepPatchChecks:DeadException" )
124
+ .doTest ();
125
+ }
126
+
98
127
@ OkToUseFoo // Foo can use itself. But this shouldn't suppress errors on *usages* of Foo.
99
128
public static final class Foo <T > {}
100
129
You can’t perform that action at this time.
0 commit comments