Search in sources :

Example 11 with ConnectedAnalysisConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.

the class ConnectedIssueMediumTest method emptyQPJava.

@Test
public void emptyQPJava() throws IOException {
    ClientInputFile inputFile = prepareJavaInputFile();
    final List<Issue> issues = new ArrayList<>();
    sonarlint.analyze(new ConnectedAnalysisConfiguration("test-project", baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
    assertThat(issues).isEmpty();
}
Also used : Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ArrayList(java.util.ArrayList) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) Test(org.junit.Test)

Example 12 with ConnectedAnalysisConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.

the class ConnectedIssueMediumTest method simpleJavaTestUnbinded.

@Test
public void simpleJavaTestUnbinded() throws Exception {
    ClientInputFile inputFile = prepareJavaTestInputFile();
    final List<Issue> issues = new ArrayList<>();
    sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
    assertThat(issues).extracting("ruleKey", "startLine", "inputFile.path", "severity").containsOnly(tuple("squid:S2187", 1, inputFile.getPath(), "MAJOR"));
}
Also used : Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ArrayList(java.util.ArrayList) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) Test(org.junit.Test)

Example 13 with ConnectedAnalysisConfiguration

use of org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration in project sonarlint-core by SonarSource.

the class ConnectedIssueMediumTest method simpleJavaScriptUnbinded.

@Test
public void simpleJavaScriptUnbinded() throws Exception {
    String ruleKey = "javascript:UnusedVariable";
    RuleDetails ruleDetails = sonarlint.getRuleDetails(ruleKey);
    assertThat(ruleDetails.getKey()).isEqualTo(ruleKey);
    assertThat(ruleDetails.getName()).isEqualTo("Unused local variables should be removed");
    assertThat(ruleDetails.getLanguage()).isEqualTo("js");
    assertThat(ruleDetails.getSeverity()).isEqualTo("MAJOR");
    assertThat(ruleDetails.getHtmlDescription()).contains("<p>", "If a local variable is declared but not used");
    assertThat(ruleDetails.getExtendedDescription()).isEmpty();
    ClientInputFile inputFile = prepareInputFile("foo.js", "function foo() {\n" + "  var x;\n" + "  var y; //NOSONAR\n" + "}", false);
    final List<Issue> issues = new ArrayList<>();
    sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
    assertThat(issues).extracting("ruleKey", "startLine", "inputFile.path").containsOnly(tuple(ruleKey, 2, inputFile.getPath()));
}
Also used : Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ArrayList(java.util.ArrayList) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) RuleDetails(org.sonarsource.sonarlint.core.client.api.common.RuleDetails) Test(org.junit.Test)

Aggregations

ConnectedAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration)13 Test (org.junit.Test)9 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)9 ArrayList (java.util.ArrayList)7 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)7 IOException (java.io.IOException)3 GlobalUpdateRequiredException (org.sonarsource.sonarlint.core.client.api.exceptions.GlobalUpdateRequiredException)3 Path (java.nio.file.Path)2 IssueListener (org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener)2 File (java.io.File)1 LinkedList (java.util.LinkedList)1 DefaultClientInputFile (org.sonarlint.daemon.model.DefaultClientInputFile)1 ProxyIssueListener (org.sonarlint.daemon.model.ProxyIssueListener)1 ProjectLogOutput (org.sonarlint.intellij.util.ProjectLogOutput)1 ConnectedSonarLintEngineImpl (org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl)1 RuleDetails (org.sonarsource.sonarlint.core.client.api.common.RuleDetails)1 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)1 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)1 InputFile (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile)1