use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilder method setFileIssues.
private void setFileIssues(VirtualFile file, Iterable<LiveIssue> issues) {
if (!accept(file)) {
removeFile(file);
return;
}
List<LiveIssue> filtered = filter(issues);
if (filtered.isEmpty()) {
removeFile(file);
return;
}
boolean newFile = false;
FileNode fNode = index.getFileNode(file);
if (fNode == null) {
newFile = true;
fNode = new FileNode(file);
index.setFileNode(fNode);
}
setIssues(fNode, filtered);
if (newFile) {
AbstractNode parent = getFilesParent();
int idx = parent.getInsertIdx(fNode, new FileNodeComparator());
int[] newIdx = { idx };
model.nodesWereInserted(parent, newIdx);
model.nodeChanged(parent);
} else {
model.nodeStructureChanged(fNode);
}
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilderTest method mockIssuePointer.
private static LiveIssue mockIssuePointer(String path, int startOffset, String rule, String severity, @Nullable Long creationDate) {
Issue issue = mock(Issue.class);
PsiFile psiFile = mock(PsiFile.class);
when(psiFile.isValid()).thenReturn(true);
ClientInputFile f = mockFile(path);
when(issue.getInputFile()).thenReturn(f);
when(issue.getRuleKey()).thenReturn(rule);
when(issue.getRuleName()).thenReturn(rule);
when(issue.getSeverity()).thenReturn(severity);
RangeMarker marker = mock(RangeMarker.class);
when(marker.getStartOffset()).thenReturn(startOffset);
LiveIssue ip = new LiveIssue(issue, psiFile);
ip.setCreationDate(creationDate);
return ip;
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class SonarLintCheckinHandlerTest method testNoUnresolvedIssues.
@Test
public void testNoUnresolvedIssues() {
future.complete(null);
LiveIssue issue = mock(LiveIssue.class);
when(issue.isResolved()).thenReturn(true);
when(issueManager.getForFile(file)).thenReturn(Collections.singleton(issue));
handler = new SonarLintCheckinHandler(globalSettings, project, checkinProjectPanel);
CheckinHandler.ReturnResult result = handler.beforeCheckin(null, null);
assertThat(result).isEqualTo(CheckinHandler.ReturnResult.COMMIT);
verify(analysisResultIssues).set(Collections.singletonMap(file, Collections.singleton(issue)), "SCM changed files");
verify(submitter).submitFilesModal(eq(Collections.singleton(file)), eq(TriggerType.CHECK_IN), any(AnalysisCallback.class));
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class AnalysisResultsTest method testContainsIssues.
@Test
public void testContainsIssues() {
VirtualFile file = mock(VirtualFile.class);
LiveIssue issue = mock(LiveIssue.class);
when(issues.lastAnalysisDate()).thenReturn(Instant.now());
when(issues.wasAnalyzed()).thenReturn(true);
when(issues.issues()).thenReturn(Collections.singletonMap(file, Collections.singleton(issue)));
assertThat(analysisResults.getLastAnalysisDate()).isNotNull();
assertThat(analysisResults.getEmptyText()).isEqualTo("No issues found");
assertThat(analysisResults.issues()).hasSize(1);
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class IssueNodeTest method createIssue.
private static LiveIssue createIssue(long date, String message) {
PsiFile file = mock(PsiFile.class);
when(file.isValid()).thenReturn(true);
Issue issue = mock(Issue.class);
when(issue.getMessage()).thenReturn(message);
when(issue.getSeverity()).thenReturn("MAJOR");
LiveIssue issuePointer = new LiveIssue(issue, file);
issuePointer.setCreationDate(date);
return issuePointer;
}
Aggregations