use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonar-java by SonarSource.
the class SonarLintTest method simpleTestFileJava.
@Test
public void simpleTestFileJava() throws Exception {
ClientInputFile inputFile = prepareInputFile("FooTest.java", "public class FooTest {\n" + " @org.junit.Test\n" + " @org.junit.Ignore\n" + // S1607(ignored test) - requires semantic
" public void testName() throws Exception {\n" + " Foo foo = new Foo();\n" + // S2970(incomplete assertions) - requires semantic
" org.assertj.core.api.Assertions.assertThat(foo.isFooActive());\n" + // S2925(thread.sleep in test)
" java.lang.Thread.sleep(Long.MAX_VALUE);" + " }\n\n" + " private static class Foo {" + " public boolean isFooActive() {" + " return false;" + " }" + " }" + "}", true);
final List<Issue> issues = new ArrayList<>();
sonarlintEngine.analyze(new StandaloneAnalysisConfiguration(baseDir.toPath(), temp.newFolder().toPath(), Collections.singletonList(inputFile), ImmutableMap.<String, String>of()), issues::add, null, null);
assertThat(issues).extracting("ruleKey", "startLine", "inputFile.path", "severity").containsOnly(// tuple("squid:S2970", 6, inputFile.getPath(), "BLOCKER"),
tuple("squid:S2925", 7, inputFile.getPath(), "MAJOR"));
}
use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonarlint-intellij by SonarSource.
the class StandaloneTest method analyze.
private static List<Issue> analyze(ClientInputFile inputFile) throws IOException {
List<Issue> issues = new ArrayList<>();
sonarlintEngine.analyze(new StandaloneAnalysisConfiguration(baseDir.toPath(), temp.newFolder().toPath(), Collections.singletonList(inputFile), Collections.emptyMap()), issues::add, null, null);
return issues;
}
Aggregations