Search in sources :

Example 1 with StandaloneGlobalConfiguration

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration in project sonar-java by SonarSource.

the class SonarLintTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    StandaloneGlobalConfiguration config = StandaloneGlobalConfiguration.builder().addPlugin(JavaTestSuite.JAVA_PLUGIN_LOCATION.getFile().toURI().toURL()).setSonarLintUserHome(temp.newFolder().toPath()).setLogOutput((formattedMessage, level) -> {
    /* Don't pollute logs*/
    }).build();
    sonarlintEngine = new StandaloneSonarLintEngineImpl(config);
    baseDir = temp.newFolder();
}
Also used : BeforeClass(org.junit.BeforeClass) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) ArrayList(java.util.ArrayList) Charset(java.nio.charset.Charset) Files(com.google.common.io.Files) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) ClassRule(org.junit.ClassRule) Path(java.nio.file.Path) StandaloneSonarLintEngine(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine) AfterClass(org.junit.AfterClass) ImmutableMap(com.google.common.collect.ImmutableMap) Assertions.tuple(org.assertj.core.api.Assertions.tuple) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) StandaloneAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration) List(java.util.List) AnalysisResults(org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeClass(org.junit.BeforeClass)

Example 2 with StandaloneGlobalConfiguration

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration in project sonarlint-intellij by SonarSource.

the class StandaloneTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    StandaloneGlobalConfiguration config = StandaloneGlobalConfiguration.builder().addPlugins(getPlugins(PLUGINS_FOLDER).toArray(new URL[0])).setSonarLintUserHome(temp.newFolder("sonarlint").toPath()).setLogOutput((msg, level) -> System.out.println("[" + level + "]: " + msg)).build();
    sonarlintEngine = new StandaloneSonarLintEngineImpl(config);
    baseDir = temp.newFolder();
}
Also used : BeforeClass(org.junit.BeforeClass) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) Assertions.tuple(org.assertj.core.api.Assertions.tuple) URL(java.net.URL) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) ArrayList(java.util.ArrayList) StandaloneAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration) List(java.util.List) Paths(java.nio.file.Paths) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ClassRule(org.junit.ClassRule) Path(java.nio.file.Path) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) StandaloneSonarLintEngine(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeClass(org.junit.BeforeClass)

Example 3 with StandaloneGlobalConfiguration

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration in project sonarlint-core by SonarSource.

the class StandaloneIssueMediumTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    Path sonarlintUserHome = temp.newFolder().toPath();
    Path fakeTypeScriptProjectPath = temp.newFolder().toPath();
    Path packagejson = fakeTypeScriptProjectPath.resolve("package.json");
    FileUtils.write(packagejson.toFile(), "{" + "\"devDependencies\": {\n" + "    \"typescript\": \"2.6.1\"\n" + "  }" + "}", StandardCharsets.UTF_8);
    ProcessBuilder pb = new ProcessBuilder("npm" + (SystemUtils.IS_OS_WINDOWS ? ".cmd" : ""), "install").directory(fakeTypeScriptProjectPath.toFile()).inheritIO();
    Process process = pb.start();
    if (process.waitFor() != 0) {
        fail("Unable to run npm install");
    }
    Map<String, String> extraProperties = new HashMap<>();
    extraProperties.put("sonar.typescript.internal.typescriptLocation", fakeTypeScriptProjectPath.resolve("node_modules").toString());
    StandaloneGlobalConfiguration config = StandaloneGlobalConfiguration.builder().addPlugin(PluginLocator.getJavaScriptPluginUrl()).addPlugin(PluginLocator.getJavaPluginUrl()).addPlugin(PluginLocator.getPhpPluginUrl()).addPlugin(PluginLocator.getPythonPluginUrl()).addPlugin(PluginLocator.getCppPluginUrl()).addPlugin(PluginLocator.getXooPluginUrl()).addPlugin(PluginLocator.getLicensePluginUrl()).addPlugin(PluginLocator.getTypeScriptPluginUrl()).setSonarLintUserHome(sonarlintUserHome).setLogOutput((msg, level) -> System.out.println(msg)).setExtraProperties(extraProperties).build();
    sonarlint = new StandaloneSonarLintEngineImpl(config);
}
Also used : Path(java.nio.file.Path) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) HashMap(java.util.HashMap) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeClass(org.junit.BeforeClass)

Example 4 with StandaloneGlobalConfiguration

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration in project sonarlint-core by SonarSource.

the class StandaloneTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    Path sonarlintUserHome = temp.newFolder().toPath();
    logs = new ArrayList<>();
    Map<String, String> globalProps = new HashMap<>();
    globalProps.put("sonar.global.label", "It works");
    StandaloneGlobalConfiguration config = StandaloneGlobalConfiguration.builder().addPlugin(new File("../plugins/global-extension-plugin/target/global-extension-plugin.jar").toURI().toURL()).setSonarLintUserHome(sonarlintUserHome).setLogOutput((msg, level) -> logs.add(msg)).setExtraProperties(globalProps).build();
    sonarlint = new StandaloneSonarLintEngineImpl(config);
    assertThat(logs).containsOnlyOnce("Start Global Extension It works");
}
Also used : Path(java.nio.file.Path) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) HashMap(java.util.HashMap) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) File(java.io.File) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeClass(org.junit.BeforeClass)

Example 5 with StandaloneGlobalConfiguration

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration in project sonar-web by SonarSource.

the class SonarLintTest method prepare.

@BeforeClass
public static void prepare() throws Exception {
    StandaloneGlobalConfiguration sonarLintConfig = StandaloneGlobalConfiguration.builder().addPlugin(FileLocation.byWildcardMavenFilename(new File("../../sonar-web-plugin/target"), "sonar-web-plugin-*.jar").getFile().toURI().toURL()).setSonarLintUserHome(temp.newFolder().toPath()).setLogOutput((formattedMessage, level) -> {
    /* Don't pollute logs */
    }).build();
    sonarlintEngine = new StandaloneSonarLintEngineImpl(sonarLintConfig);
    baseDir = temp.newFolder();
}
Also used : AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FileLocation(com.sonar.orchestrator.locator.FileLocation) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) IOException(java.io.IOException) HashMap(java.util.HashMap) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) StandaloneAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) Charset(java.nio.charset.Charset) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) Issue(org.sonarsource.sonarlint.core.client.api.common.analysis.Issue) ClassRule(org.junit.ClassRule) Path(java.nio.file.Path) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) StandaloneSonarLintEngine(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine) StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) File(java.io.File) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

StandaloneSonarLintEngineImpl (org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)6 StandaloneGlobalConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration)6 Path (java.nio.file.Path)5 BeforeClass (org.junit.BeforeClass)5 File (java.io.File)4 IOException (java.io.IOException)4 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)4 StandardCharsets (java.nio.charset.StandardCharsets)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.tuple (org.assertj.core.api.Assertions.tuple)3 ClassRule (org.junit.ClassRule)3 Test (org.junit.Test)3 TemporaryFolder (org.junit.rules.TemporaryFolder)3 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)3 StandaloneAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration)3 StandaloneSonarLintEngine (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine)3