use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class ConnectedIssueExclusionsMediumTest method prepareInputFile.
private ClientInputFile prepareInputFile(String relativePath, String content, final boolean isTest) throws IOException {
final File file = new File(baseDir, relativePath);
FileUtils.write(file, content);
ClientInputFile inputFile = TestUtils.createInputFile(file.toPath(), relativePath, isTest);
return inputFile;
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile 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"));
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile 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"));
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class ConnectedStaleStorageMediumTest method test_stale_global.
@Test
public void test_stale_global() throws Exception {
writeUpdateStatus(storage, "0");
ConnectedSonarLintEngine sonarlint = new ConnectedSonarLintEngineImpl(config);
assertThat(sonarlint.getState()).isEqualTo(State.NEED_UPDATE);
assertThat(sonarlint.getGlobalStorageStatus()).isNotNull();
assertThat(sonarlint.getModuleStorageStatus("foo")).isNull();
try {
sonarlint.allModulesByKey();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.getRuleDetails("rule");
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
try {
sonarlint.analyze(new ConnectedAnalysisConfiguration(null, baseDir.toPath(), temp.newFolder().toPath(), Collections.<ClientInputFile>emptyList(), ImmutableMap.<String, String>of()), mock(IssueListener.class), null, null);
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isInstanceOf(GlobalUpdateRequiredException.class).hasMessage("Please update server 'localhost'");
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-core by SonarSource.
the class StandaloneIssueMediumTest method simplePython.
@Test
public void simplePython() throws Exception {
ClientInputFile inputFile = prepareInputFile("foo.py", "def my_function(name):\n" + " print \"Hello\"\n" + " print \"world!\" # NOSONAR\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").containsOnly(tuple("python:PrintStatementUsage", 2, inputFile.getPath()));
}
Aggregations