use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesDisableErrorsOnlyForEnabledChecks.
@Test
public void applyOverridesDisableErrorsOnlyForEnabledChecks() {
Supplier<ScannerSupplier> filteredScanner = () -> ScannerSupplier.fromBugCheckerClasses(BadShiftAmount.class, UnsuppressibleArrayEquals.class, EqualsIncompatibleType.class).filter(p -> !p.checkerClass().equals(EqualsIncompatibleType.class));
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllErrorsAsWarnings"));
assertScanner(filteredScanner.get().applyOverrides(epOptions)).hasEnabledChecks(UnsuppressibleArrayEquals.class, BadShiftAmount.class);
epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllErrorsAsWarnings", "-Xep:BadShiftAmount:OFF"));
assertScanner(filteredScanner.get().applyOverrides(epOptions)).hasEnabledChecks(UnsuppressibleArrayEquals.class);
}
use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesDisableErrors.
@Test
public void applyOverridesDisableErrors() {
// BadShiftAmount (error), ArrayEquals (unsuppressible error), StringEquality (warning)
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(BadShiftAmount.class, UnsuppressibleArrayEquals.class, StringEquality.class);
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllErrorsAsWarnings"));
assertScanner(ss.applyOverrides(epOptions)).hasSeverities(ImmutableMap.of(// Unsuppressible, not demoted
"ArrayEquals", // Unsuppressible, not demoted
SeverityLevel.ERROR, // Demoted from error to warning
"BadShiftAmount", // Demoted from error to warning
SeverityLevel.WARNING, "StringEquality", // Already warning, unaffected
SeverityLevel.WARNING));
// Flags after AllErrorsAsWarnings flag should override it.
epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllErrorsAsWarnings", "-Xep:StringEquality:ERROR"));
assertScanner(ss.applyOverrides(epOptions)).hasSeverities(ImmutableMap.of("ArrayEquals", SeverityLevel.ERROR, "BadShiftAmount", SeverityLevel.WARNING, "StringEquality", SeverityLevel.ERROR));
// AllErrorsAsWarnings flag should override all error-level severity flags that come before it.
epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-Xep:StringEquality:ERROR", "-XepAllErrorsAsWarnings"));
assertScanner(ss.applyOverrides(epOptions)).hasSeverities(ImmutableMap.of("ArrayEquals", SeverityLevel.ERROR, "BadShiftAmount", SeverityLevel.WARNING, "StringEquality", SeverityLevel.WARNING));
// AllErrorsAsWarnings only overrides error-level severity flags.
// That is, checks disabled before the flag are left disabled, not promoted to warnings.
epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-Xep:BadShiftAmount:OFF", "-XepAllErrorsAsWarnings"));
assertScanner(ss.applyOverrides(epOptions)).hasSeverities(ImmutableMap.of("ArrayEquals", SeverityLevel.ERROR, "StringEquality", SeverityLevel.WARNING));
assertScanner(ss.applyOverrides(epOptions)).hasEnabledChecks(UnsuppressibleArrayEquals.class, StringEquality.class);
}
Aggregations