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(
224224 .customRefactorer ()
225225 .or (
226226 () -> {
227- ScannerSupplier toUse =
228- ErrorPronePlugins .loadPlugins (scannerSupplier , context )
229- .applyOverrides (epOptions );
227+ ScannerSupplier toUse = ErrorPronePlugins .loadPlugins (scannerSupplier , context );
230228 ImmutableSet <String > namedCheckers = epOptions .patchingOptions ().namedCheckers ();
231229 if (!namedCheckers .isEmpty ()) {
232230 toUse = toUse .filter (bci -> namedCheckers .contains (bci .canonicalName ()));
231+ } else {
232+ toUse = toUse .applyOverrides (epOptions );
233233 }
234234 return ErrorProneScannerTransformer .create (toUse .get ());
235235 })
Original file line number Diff line number Diff line change @@ -95,6 +95,35 @@ public void suppressionAnnotationIgnoredWithOptions() {
9595 .doTest ();
9696 }
9797
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+
98127 @ OkToUseFoo // Foo can use itself. But this shouldn't suppress errors on *usages* of Foo.
99128 public static final class Foo <T > {}
100129
You can’t perform that action at this time.
0 commit comments