Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLI-1316 Have a common way of computing resolved findings #1199

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public void filterTaintVulnerabilityTab(boolean isResolved) {
if (taintContent != null) {
var taintPanel = (TaintVulnerabilitiesPanel) taintContent.getComponent();
taintPanel.allowResolvedTaintVulnerabilities(isResolved);
taintContent.setDisplayName(buildTabName(getService(project, TaintVulnerabilitiesCache.class).getFocusAwareCount(isResolved),
SonarLintToolWindowFactory.TAINT_VULNERABILITIES_TAB_TITLE));
}
}

Expand Down Expand Up @@ -231,6 +233,8 @@ public void refreshViews() {
if (taintContent != null) {
var taintPanel = (TaintVulnerabilitiesPanel) taintContent.getComponent();
taintPanel.applyFocusOnNewCodeSettings();
taintContent.setDisplayName(buildTabName(getService(project, TaintVulnerabilitiesCache.class).getFocusAwareCount(),
SonarLintToolWindowFactory.TAINT_VULNERABILITIES_TAB_TITLE));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.sonarlint.intellij.common.util.SonarLintUtils.getService

@Service(Service.Level.PROJECT)
class TaintVulnerabilitiesCache(val project: Project) {
private var isResolvedState = false
var taintVulnerabilities: List<LocalTaintVulnerability> = emptyList()

fun update(taintVulnerabilityIdsToRemove: Set<UUID>, taintVulnerabilitiesToAdd: List<LocalTaintVulnerability>, taintVulnerabilitiesToUpdate: List<LocalTaintVulnerability>) {
Expand All @@ -53,8 +54,10 @@ class TaintVulnerabilitiesCache(val project: Project) {
return taintVulnerabilities.filter { it.file() == file }
}

fun getFocusAwareCount(): Int {
@JvmOverloads
fun getFocusAwareCount(isResolved: Boolean? = null): Int {
val isFocusOnNewCode = getService(CleanAsYouCodeService::class.java).shouldFocusOnNewCode(project)
return taintVulnerabilities.count { !it.isResolved() && (!isFocusOnNewCode || it.isOnNewCode()) }
isResolved?.let { isResolvedState = it }
return taintVulnerabilities.count { (isResolvedState || !it.isResolved()) && (!isFocusOnNewCode || it.isOnNewCode()) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class TaintVulnerabilitiesPanel(private val project: Project) : SimpleToolWindow
}
}

fun switchCard() {
private fun switchCard() {
when {
!getService(BackendService::class.java).isAlive() -> {
showCard(ERROR_CARD_ID)
Expand Down