use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonar-web by SonarSource.
the class SonarLintTest method should_raise_three_issues.
@Test
public void should_raise_three_issues() throws IOException {
ClientInputFile inputFile = prepareInputFile("foo.html", "<html>\n" + "<body>\n" + "<a href=\"foo.png\">a</a>\n" + "</body>\n" + "</html>\n", false);
List<Issue> issues = new ArrayList<>();
sonarlintEngine.analyze(new StandaloneAnalysisConfiguration(baseDir.toPath(), temp.newFolder().toPath(), Collections.singletonList(inputFile), new HashMap<>()), issues::add);
assertThat(issues).extracting("ruleKey", "startLine", "inputFile.path", "severity").containsOnly(tuple("Web:DoctypePresenceCheck", 1, inputFile.getPath(), "MAJOR"), tuple("Web:LinkToImageCheck", 3, inputFile.getPath(), "MAJOR"), tuple("Web:PageWithoutTitleCheck", 1, inputFile.getPath(), "MAJOR"));
}
use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonar-java by SonarSource.
the class SonarLintTest method parse_error_should_report_analysis_error.
@Test
public void parse_error_should_report_analysis_error() throws Exception {
ClientInputFile inputFile = prepareInputFile("ParseError.java", "class ParseError {", false);
final List<Issue> issues = new ArrayList<>();
AnalysisResults analysisResults = sonarlintEngine.analyze(new StandaloneAnalysisConfiguration(baseDir.toPath(), temp.newFolder().toPath(), Collections.singletonList(inputFile), ImmutableMap.<String, String>of()), issues::add, null, null);
assertThat(issues).isEmpty();
assertThat(analysisResults.failedAnalysisFiles()).hasSize(1);
}
use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonar-java by SonarSource.
the class SonarLintTest method supportJavaSuppressWarning.
@Test
public void supportJavaSuppressWarning() throws Exception {
ClientInputFile inputFile = prepareInputFile("Foo.java", "public class Foo {\n" + " @SuppressWarnings(\"squid:S106\")\n" + " public void foo() {\n" + " int x;\n" + " System.out.println(\"Foo\");\n" + " System.out.println(\"Foo\"); //NOSONAR\n" + " }\n" + "}", false);
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:S1220", null, inputFile.getPath(), "MINOR"), tuple("squid:S1481", 4, inputFile.getPath(), "MINOR"));
}
use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonarlint-intellij by SonarSource.
the class StandaloneSonarLintFacade method analyze.
@Override
protected AnalysisResults analyze(Path baseDir, Path workDir, Collection<ClientInputFile> inputFiles, Map<String, String> props, IssueListener issueListener, ProgressMonitor progressMonitor) {
StandaloneAnalysisConfiguration config = new StandaloneAnalysisConfiguration(baseDir, workDir, inputFiles, props);
console.debug("Starting analysis with configuration:\n" + config.toString());
return sonarlint.analyze(config, issueListener, new ProjectLogOutput(console, projectSettings), progressMonitor);
}
use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration in project sonarlint-core by SonarSource.
the class StandaloneIssueMediumTest method simpleJava.
@Test
public void simpleJava() throws Exception {
ClientInputFile inputFile = prepareInputFile("Foo.java", "public class Foo {\n" + " public void foo() {\n" + " int x;\n" + " System.out.println(\"Foo\");\n" + " }\n" + "}", false);
final List<Issue> issues = new ArrayList<>();
sonarlint.analyze(new StandaloneAnalysisConfiguration(baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.of()), issue -> issues.add(issue), null, null);
assertThat(issues).extracting("ruleKey", "startLine", "inputFile.path", "severity").containsOnly(tuple("squid:S106", 4, inputFile.getPath(), "MAJOR"), tuple("squid:S1220", null, inputFile.getPath(), "MINOR"), tuple("squid:S1481", 3, inputFile.getPath(), "MINOR"));
}
Aggregations