Search in sources :

Example 1 with ConnectedAnalysisConfiguration

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

the class AbstractConnectedTest method createAnalysisConfiguration.

protected ConnectedAnalysisConfiguration createAnalysisConfiguration(String projectKey, String projectDir, String filePath, String... properties) throws IOException {
    final Path baseDir = Paths.get("projects/" + projectDir).toAbsolutePath();
    final Path path = baseDir.resolve(filePath);
    return new ConnectedAnalysisConfiguration(projectKey, new File("projects/" + projectDir).toPath().toAbsolutePath(), t.newFolder().toPath(), Collections.singletonList(new TestClientInputFile(baseDir, path, false, StandardCharsets.UTF_8)), toMap(properties));
}
Also used : Path(java.nio.file.Path) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) File(java.io.File)

Example 2 with ConnectedAnalysisConfiguration

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

the class ConnectedIssueExclusionsMediumTest method collectIssues.

private List<Issue> collectIssues(ClientInputFile inputFile1, ClientInputFile inputFile2) throws IOException {
    final List<Issue> issues = new ArrayList<>();
    sonarlint.analyze(new ConnectedAnalysisConfiguration(JAVA_MODULE_KEY, baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile1, inputFile2), ImmutableMap.<String, String>of()), new StoreIssueListener(issues), null, null);
    return issues;
}
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)

Example 3 with ConnectedAnalysisConfiguration

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

the class ConnectedIssueMediumTest method simpleJavaUnbinded.

@Test
public void simpleJavaUnbinded() throws Exception {
    ClientInputFile inputFile = prepareJavaInputFile();
    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:S106", 4, inputFile.getPath(), "MAJOR"), tuple("squid:S1220", null, inputFile.getPath(), "MINOR"), tuple("squid:S1481", 3, 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 4 with ConnectedAnalysisConfiguration

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

the class ConnectedIssueMediumTest method testStaleModule.

@Test
public void testStaleModule() throws IOException {
    assertThat(sonarlint.getModuleStorageStatus("stale_module").isStale()).isTrue();
    ConnectedAnalysisConfiguration config = new ConnectedAnalysisConfiguration("stale_module", baseDir.toPath(), temp.newFolder().toPath(), Collections.<ClientInputFile>emptyList(), ImmutableMap.<String, String>of());
    try {
        sonarlint.analyze(config, createNoOpIssueListener(), null, null);
        fail("Expected exception");
    } catch (Exception e) {
        assertThat(e).isInstanceOf(StorageException.class).hasMessage("Stored data for module 'stale_module' is stale because it was created with a different version of SonarLint. Please update the binding.");
    }
}
Also used : ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) StorageException(org.sonarsource.sonarlint.core.client.api.exceptions.StorageException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with ConnectedAnalysisConfiguration

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

the class ConnectedIssueMediumTest method simpleJavaBinded.

@Test
public void simpleJavaBinded() throws Exception {
    ClientInputFile inputFile = prepareJavaInputFile();
    final List<Issue> issues = new ArrayList<>();
    sonarlint.analyze(new ConnectedAnalysisConfiguration(JAVA_MODULE_KEY, 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:S106", 4, inputFile.getPath(), "MAJOR"), tuple("squid:S1220", null, inputFile.getPath(), "MINOR"), tuple("squid:S1481", 3, 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)

Aggregations

ConnectedAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration)14 Test (org.junit.Test)9 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)9 ArrayList (java.util.ArrayList)8 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)7 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 IssueListener (org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener)3 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)2 GlobalUpdateRequiredException (org.sonarsource.sonarlint.core.client.api.exceptions.GlobalUpdateRequiredException)2 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)2 File (java.io.File)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1