use of org.sonarsource.sonarlint.core.analysis.api.Issue in project sonarlint-core by SonarSource.
the class DefaultClientIssueTests method transformIssue.
@Test
void transformIssue() {
var currentFile = mock(InputComponent.class);
var currentFileKey = "currentFileKey";
when(currentFile.key()).thenReturn(currentFileKey);
var anotherFile = mock(InputComponent.class);
when(anotherFile.key()).thenReturn("anotherFileKey");
textRange = new TextRange(1, 2, 2, 3);
when(rule.getName()).thenReturn("name");
when(rule.getType()).thenReturn("BUG");
when(rule.getSeverity()).thenReturn("MAJOR");
var issue = new Issue("rule:S123", "msg", textRange, clientInputFile, null, null);
var underTest = new DefaultClientIssue(issue, rule);
assertThat(underTest.getStartLine()).isEqualTo(1);
assertThat(underTest.getStartLineOffset()).isEqualTo(2);
assertThat(underTest.getEndLine()).isEqualTo(2);
assertThat(underTest.getEndLineOffset()).isEqualTo(3);
assertThat(underTest.getMessage()).isEqualTo("msg");
assertThat(underTest.getSeverity()).isEqualTo("MAJOR");
assertThat(underTest.getType()).isEqualTo("BUG");
assertThat(underTest.getInputFile()).isEqualTo(clientInputFile);
}
use of org.sonarsource.sonarlint.core.analysis.api.Issue in project sonarlint-core by SonarSource.
the class DefaultFilterableIssueTests method delegate_textRange_to_rawIssue.
@Test
void delegate_textRange_to_rawIssue() {
TextRange textRange = new DefaultTextRange(new DefaultTextPointer(0, 1), new DefaultTextPointer(2, 3));
var activeRule = mock(ActiveRuleAdapter.class);
when(activeRule.ruleKey()).thenReturn(RuleKey.of("foo", "S123"));
var rawIssue = new Issue(activeRule, null, textRange, null, null, null);
FilterableIssue underTest = new DefaultFilterableIssue(rawIssue, mock(InputComponent.class));
assertThat(underTest.textRange()).usingRecursiveComparison().isEqualTo(textRange);
}
use of org.sonarsource.sonarlint.core.analysis.api.Issue in project sonarlint-core by SonarSource.
the class AnalysisEngineMediumTests method should_analyze_a_file_inside_a_module.
@Test
void should_analyze_a_file_inside_a_module(@TempDir Path baseDir) throws Exception {
var content = "def foo():\n" + " x = 9; # trailing comment\n";
ClientInputFile inputFile = preparePythonInputFile(baseDir, content);
AnalysisConfiguration analysisConfig = AnalysisConfiguration.builder().addInputFiles(inputFile).addActiveRules(trailingCommentRule()).setBaseDir(baseDir).build();
List<Issue> issues = new ArrayList<>();
analysisEngine.post(new RegisterModuleCommand(new ClientModuleInfo("moduleKey", aModuleFileSystem())), progressMonitor).get();
analysisEngine.post(new AnalyzeCommand("moduleKey", analysisConfig, issues::add, null), progressMonitor).get();
assertThat(issues).extracting("ruleKey", "message", "inputFile", "flows", "quickFixes", "textRange.startLine", "textRange.startLineOffset", "textRange.endLine", "textRange.endLineOffset").containsOnly(tuple("python:S139", "Move this trailing comment on the previous empty line.", inputFile, List.of(), List.of(), 2, 9, 2, 27));
}
Aggregations