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

fix: cache cleaning and some name refactorings [IDE-134] #480

Merged
merged 3 commits into from
Mar 5, 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 @@ -71,7 +71,7 @@ class SnykCodeBulkFileListener : SnykBulkFileListener() {
val filesAffected = toSnykCodeFileSet(project, virtualFilesAffected)

if (isSnykCodeLSEnabled()) {
processAfterForLS(filesAffected, project)
updateCacheAndUI(filesAffected, project)
return
}
/* update .dcignore caches if needed */
Expand All @@ -98,7 +98,7 @@ class SnykCodeBulkFileListener : SnykBulkFileListener() {
}
}

private fun processAfterForLS(filesAffected: Set<SnykCodeFile>, project: Project) {
private fun updateCacheAndUI(filesAffected: Set<SnykCodeFile>, project: Project) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔝 🙇‍♀️

val cache = getSnykCachedResults(project)?.currentSnykCodeResultsLS ?: return
filesAffected.forEach {
cache.remove(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SnykToolWindowSnykCodeScanListenerLS(
.map { it.key to it.value.filter { issue -> issue.additionalData.isSecurityType } }
.toMap()
securityIssuesCount = securityResults.values.flatten().distinct().size
securityIssuesHMLPostfix = buildHMLpostfix(securityResults)
securityIssuesHMLPostfix = buildSeveritiesPostfixForFileNode(securityResults)

if (pluginSettings().treeFiltering.codeSecurityResults) {
val securityResultsToDisplay = securityResults.map { entry ->
Expand Down Expand Up @@ -103,7 +103,7 @@ class SnykToolWindowSnykCodeScanListenerLS(
.map { it.key to it.value.filter { issue -> !issue.additionalData.isSecurityType } }
.toMap()
qualityIssuesCount = qualityResults.values.flatten().distinct().size
qualityIssuesHMLPostfix = buildHMLpostfix(qualityResults)
qualityIssuesHMLPostfix = buildSeveritiesPostfixForFileNode(qualityResults)

if (pluginSettings().treeFiltering.codeQualityResults) {
val qualityResultsToDisplay = qualityResults.map { entry ->
Expand Down Expand Up @@ -157,7 +157,7 @@ class SnykToolWindowSnykCodeScanListenerLS(
}
}

private fun buildHMLpostfix(securityResults: Map<SnykCodeFile, List<ScanIssue>>): String {
private fun buildSeveritiesPostfixForFileNode(securityResults: Map<SnykCodeFile, List<ScanIssue>>): String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

val high = securityResults.values.flatten().count { it.getSeverityAsEnum() == Severity.HIGH }
val medium = securityResults.values.flatten().count { it.getSeverityAsEnum() == Severity.MEDIUM }
val low = securityResults.values.flatten().count { it.getSeverityAsEnum() == Severity.LOW }
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/snyk/common/SnykCachedResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SnykCachedResults(val project: Project) {
currentOssError = null
currentContainerError = null
currentIacError = null
// currentSnykCodeResultsLS = null
currentSnykCodeResultsLS.clear()
currentSnykCodeResults = null
currentSnykCodeError = null
}
Expand Down Expand Up @@ -125,7 +125,7 @@ class SnykCachedResults(val project: Project) {
object : SnykCodeScanListenerLS {
val logger = logger<SnykCachedResults>()
override fun scanningStarted(snykScan: SnykScanParams) {
logger.info("scanningStarted for project ${project.name}, emptying cache.")
logger.info("scanningStarted for project ${project.name}")
}

override fun scanningSnykCodeFinished(snykCodeResults: Map<SnykCodeFile, List<ScanIssue>>) {
Expand Down
Loading