use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesEnablesCheck.
@Test
public void applyOverridesEnablesCheck() throws Exception {
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(ArrayEquals.class, BadShiftAmount.class, StaticQualifiedUsingExpression.class).filter(// disables all checks
Predicates.alwaysFalse());
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-Xep:ArrayEquals", "-Xep:BadShiftAmount"));
assertScanner(ss.applyOverrides(epOptions)).hasEnabledChecks(ArrayEquals.class, BadShiftAmount.class);
}
use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesThrowsExceptionWhenDemotingNonDisablableCheck.
@Test
public void applyOverridesThrowsExceptionWhenDemotingNonDisablableCheck() throws Exception {
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(ErrorProneJavaCompilerTest.UnsuppressibleArrayEquals.class);
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-Xep:ArrayEquals:WARN"));
InvalidCommandLineOptionException exception = expectThrows(InvalidCommandLineOptionException.class, () -> ss.applyOverrides(epOptions));
assertThat(exception.getMessage()).contains("may not be demoted to a warning");
}
use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesSetsSeverity.
@Test
public void applyOverridesSetsSeverity() throws Exception {
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(BadShiftAmount.class, ChainingConstructorIgnoresParameter.class, StringEquality.class);
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-Xep:ChainingConstructorIgnoresParameter:WARN", "-Xep:StringEquality:ERROR"));
ScannerSupplier overriddenScannerSupplier = ss.applyOverrides(epOptions);
Map<String, SeverityLevel> expected = ImmutableMap.of("BadShiftAmount", SeverityLevel.ERROR, "ChainingConstructorIgnoresParameter", SeverityLevel.WARNING, "StringEquality", SeverityLevel.ERROR);
assertScanner(overriddenScannerSupplier).hasSeverities(expected);
}
use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesEnableAllChecks.
@Test
public void applyOverridesEnableAllChecks() throws Exception {
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(ArrayEquals.class, BadShiftAmount.class, StaticQualifiedUsingExpression.class).filter(// disables all checks
Predicates.alwaysFalse());
// assert empty scanner has no enabled checks
assertScanner(ss).hasEnabledChecks();
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllDisabledChecksAsWarnings"));
assertScanner(ss.applyOverrides(epOptions)).hasEnabledChecks(ArrayEquals.class, BadShiftAmount.class, StaticQualifiedUsingExpression.class);
epOptions = ErrorProneOptions.processArgs(ImmutableList.of("-XepAllDisabledChecksAsWarnings", "-Xep:ArrayEquals:OFF"));
assertScanner(ss.applyOverrides(epOptions)).hasEnabledChecks(BadShiftAmount.class, StaticQualifiedUsingExpression.class);
// The 'AllDisabledChecksAsWarnings' flag doesn't populate through to additional plugins
assertScanner(ss.applyOverrides(epOptions).plus(ScannerSupplier.fromBugCheckerClasses(DivZero.class).filter(t -> false))).hasEnabledChecks(BadShiftAmount.class, StaticQualifiedUsingExpression.class);
}
use of com.google.errorprone.ErrorProneOptions in project error-prone by google.
the class ScannerSupplierTest method applyOverridesWorksOnEmptySeverityMap.
@Test
@SuppressWarnings("unchecked")
public void applyOverridesWorksOnEmptySeverityMap() throws Exception {
ScannerSupplier ss = ScannerSupplier.fromBugCheckerClasses(ChainingConstructorIgnoresParameter.class, DepAnn.class, LongLiteralLowerCaseSuffix.class);
ErrorProneOptions epOptions = ErrorProneOptions.processArgs(Collections.emptyList());
assertScanner(ss.applyOverrides(epOptions)).hasEnabledChecks(ChainingConstructorIgnoresParameter.class, DepAnn.class, LongLiteralLowerCaseSuffix.class);
}
Aggregations