本文整理汇总了Java中com.google.errorprone.bugpatterns.EmptyIfStatement类的典型用法代码示例。如果您正苦于以下问题:Java EmptyIfStatement类的具体用法?Java EmptyIfStatement怎么用?Java EmptyIfStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmptyIfStatement类属于com.google.errorprone.bugpatterns包,在下文中一共展示了EmptyIfStatement类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canEnableWithOverriddenSeverity
import com.google.errorprone.bugpatterns.EmptyIfStatement; //导入依赖的package包/类
@Test
public void canEnableWithOverriddenSeverity() throws Exception {
ErrorProneTestCompiler compiler = builder.build();
List<JavaFileObject> sources =
compiler
.fileManager()
.forResources(EmptyIfStatement.class, "testdata/EmptyIfStatementPositiveCases.java");
Result exitCode = compiler.compile(sources);
assertThat(exitCode).isEqualTo(Result.OK);
assertThat(diagnosticHelper.getDiagnostics()).isEmpty();
diagnosticHelper.clearDiagnostics();
exitCode = compiler.compile(new String[] {"-Xep:EmptyIf:WARN"}, sources);
assertThat(exitCode).isEqualTo(Result.OK);
assertThat(diagnosticHelper.getDiagnostics()).isNotEmpty();
assertThat(diagnosticHelper.getDiagnostics().toString()).contains("[EmptyIf]");
}
示例2: canEnableWithDefaultSeverity
import com.google.errorprone.bugpatterns.EmptyIfStatement; //导入依赖的package包/类
@Test
public void canEnableWithDefaultSeverity() throws Exception {
ErrorProneTestCompiler compiler = builder.build();
List<JavaFileObject> sources =
compiler
.fileManager()
.forResources(EmptyIfStatement.class, "testdata/EmptyIfStatementPositiveCases.java");
Result exitCode = compiler.compile(sources);
assertThat(exitCode).isEqualTo(Result.OK);
assertThat(diagnosticHelper.getDiagnostics()).isEmpty();
exitCode = compiler.compile(new String[] {"-Xep:EmptyIf"}, sources);
assertThat(exitCode).isEqualTo(Result.ERROR);
}
示例3: setUp
import com.google.errorprone.bugpatterns.EmptyIfStatement; //导入依赖的package包/类
@Before
public void setUp() {
compiler = new ErrorProneTestCompiler.Builder()
.report(new ErrorProneScanner(new EnabledPredicate() {
@SuppressWarnings("unchecked")
@Override
public boolean isEnabled(Class<? extends BugChecker> check, BugPattern annotation) {
return asList(DeadException.class, EmptyIfStatement.class, SelfAssignment.class)
.contains(check);
}
}))
.build();
}