File tree Expand file tree Collapse file tree
check_api/src/main/java/com/google/errorprone
core/src/test/java/com/google/errorprone/scanner Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,8 +228,10 @@ static ErrorProneAnalyzer createAnalyzer(
228228 ImmutableSet <String > namedCheckers = epOptions .patchingOptions ().namedCheckers ();
229229 if (!namedCheckers .isEmpty ()) {
230230 toUse = toUse .filter (bci -> namedCheckers .contains (bci .canonicalName ()));
231+ } else {
232+ toUse = toUse .applyOverrides (epOptions );
231233 }
232- return ErrorProneScannerTransformer .create (toUse .applyOverrides ( epOptions ). get ());
234+ return ErrorProneScannerTransformer .create (toUse .get ());
233235 })
234236 .get ();
235237
Original file line number Diff line number Diff line change @@ -106,11 +106,26 @@ public void dontRunPatchForDisabledChecks() {
106106 "}" )
107107 .setArgs (
108108 "-XepPatchLocation:IN_PLACE" ,
109- "-XepPatchChecks:ShouldNotUseFoo " ,
109+ "-XepPatchChecks:" ,
110110 "-Xep:ShouldNotUseFoo:OFF" )
111111 .doTest ();
112112 }
113113
114+ @ Test
115+ public void dontRunPatchUnlessRequested () {
116+ compilationHelper .addSourceLines (
117+ "Test.java" ,
118+ "import com.google.errorprone.scanner.ScannerTest.Foo;" ,
119+ "class Test {" ,
120+ " Foo foo;" ,
121+ "}" )
122+ .setArgs (
123+ "-XepPatchLocation:IN_PLACE" ,
124+ "-Xep:ShouldNotUseFoo:WARN" ,
125+ "-XepPatchChecks:DeadException"
126+ ).doTest ();
127+ }
128+
114129 @ OkToUseFoo // Foo can use itself. But this shouldn't suppress errors on *usages* of Foo.
115130 public static final class Foo <T > {}
116131
You can’t perform that action at this time.
0 commit comments