use of org.sonarsource.sonarlint.core.client.api.common.RuleDetails in project sonarlint-intellij by SonarSource.
the class ConnectedSonarLintFacadeTest method should_get_rule_name.
@Test
public void should_get_rule_name() {
RuleDetails ruleDetails = mock(RuleDetails.class);
when(ruleDetails.getName()).thenReturn("name");
when(engine.getRuleDetails("rule1")).thenReturn(ruleDetails);
assertThat(facade.getRuleName("rule1")).isEqualTo("name");
assertThat(facade.getRuleName("invalid")).isNull();
}
use of org.sonarsource.sonarlint.core.client.api.common.RuleDetails 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()));
}
use of org.sonarsource.sonarlint.core.client.api.common.RuleDetails in project sonarlint-intellij by SonarSource.
the class ConnectedSonarLintFacadeTest method should_get_description.
@Test
public void should_get_description() {
RuleDetails ruleDetails = mock(RuleDetails.class);
when(ruleDetails.getExtendedDescription()).thenReturn("desc");
when(ruleDetails.getHtmlDescription()).thenReturn("html");
when(engine.getRuleDetails("rule1")).thenReturn(ruleDetails);
assertThat(facade.getDescription("rule1")).isEqualTo("html<br/><br/>desc");
assertThat(facade.getDescription("invalid")).isNull();
}
use of org.sonarsource.sonarlint.core.client.api.common.RuleDetails in project sonarlint-intellij by SonarSource.
the class StandaloneSonarLintFacadeTest method should_get_rule_name.
@Test
public void should_get_rule_name() {
RuleDetails ruleDetails = mock(RuleDetails.class);
when(ruleDetails.getName()).thenReturn("name");
when(engine.getRuleDetails("rule1")).thenReturn(ruleDetails);
assertThat(facade.getRuleName("rule1")).isEqualTo("name");
assertThat(facade.getRuleName("invalid")).isNull();
}
Aggregations