Skip to content

Commit

Permalink
Merge branch 'master' into task/nq/next-dev-ite
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel authored Dec 6, 2024
2 parents 5f5380f + 002171a commit 36b5c44
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 27 deletions.
42 changes: 25 additions & 17 deletions git/src/main/kotlin/org/sonarlint/intellij/git/GitRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
*/
package org.sonarlint.intellij.git

import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import git4idea.GitRevisionNumber
import git4idea.commands.Git
import git4idea.commands.GitCommand
import git4idea.commands.GitLineHandler
Expand Down Expand Up @@ -74,15 +76,14 @@ class GitRepo(private val repo: GitRepository, private val project: Project) : V
}

private fun distance(project: Project, repository: GitRepository, from: String, to: String): Int? {
val mergeBase = try {
GitHistoryUtils.getMergeBase(project, repository.root, from, to) ?: return null
} catch (e: IllegalStateException) {
// SLI-1381: "There is no ProgressIndicator or Job in this thread" should simply be a loud error
SonarLintConsole.get(project).debug("Couldn't compute the git distance, reason: ${e.message}")
return null
}
val aheadCount = getNumberOfCommitsBetween(repository, from, mergeBase.asString()) ?: return null
val behindCount = getNumberOfCommitsBetween(repository, to, mergeBase.asString()) ?: return null
val revisionNumber = ProgressManager.getInstance().runProcessWithProgressSynchronously<GitRevisionNumber, Exception>(
{ GitHistoryUtils.getMergeBase(project, repository.root, from, to) },
"SonarQube: Computing branch information",
true,
repository.project
)
val aheadCount = getNumberOfCommitsBetween(repository, from, revisionNumber.asString()) ?: return null
val behindCount = getNumberOfCommitsBetween(repository, to, revisionNumber.asString()) ?: return null
return aheadCount + behindCount
}

Expand All @@ -91,13 +92,20 @@ class GitRepo(private val repo: GitRepository, private val project: Project) : V
from: String,
to: String,
): Int? {
val handler = GitLineHandler(repository.project, repository.root, GitCommand.REV_LIST)
handler.addParameters("--count", "$from..$to")
handler.setSilent(true)
return try {
Integer.parseInt(Git.getInstance().runCommand(handler).getOutputOrThrow().trim())
} catch (e: Exception) {
throw Exception("Cannot get number of commits between '$from' and '$to'", e)
}
return ProgressManager.getInstance().runProcessWithProgressSynchronously<Int?, Exception>(
{
val handler = GitLineHandler(repository.project, repository.root, GitCommand.REV_LIST)
handler.addParameters("--count", "$from..$to")
handler.setSilent(true)
try {
Integer.parseInt(Git.getInstance().runCommand(handler).getOutputOrThrow().trim())
} catch (e: Exception) {
throw Exception("Cannot get number of commits between '$from' and '$to'", e)
}
},
"SonarQube: Computing branch information",
true,
repository.project
)
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
sonarlint-core = "10.11.1.79701"
sonarlint-core = "10.11.2.79730"

sonar-java = "8.7.0.37452"
sonar-javascript = "10.18.0.28572"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ object SonarLintIntelliJClient : SonarLintRpcClientDelegate {
}
} ?: return null
val repo = repositories.first()
return repo.electBestMatchingServerBranchForCurrentHead(mainBranchName, allBranchesNames) ?: mainBranchName
return computeOnPooledThread("Electing best matching branch") {
repo.electBestMatchingServerBranchForCurrentHead(mainBranchName, allBranchesNames) ?: mainBranchName
}
}

override fun matchProjectBranch(
Expand Down Expand Up @@ -743,7 +745,7 @@ object SonarLintIntelliJClient : SonarLintRpcClientDelegate {
filesInContentRoots.addAll(it.listFiles(module))
}

val forcedLanguages = collectContributedLanguages(module, filesInContentRoots)
val forcedLanguages = collectContributedLanguages(module, filesInContentRoots).toMap()

val clientFiles = filesInContentRoots.mapNotNull { file ->
val forcedLanguage = forcedLanguages[file]?.let { fl -> Language.valueOf(fl.name) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class OnTheFlyFindingsHolder(private val project: Project) : FileEditorManagerLi
currentSecurityHotspotsPerOpenFile.remove(file)
// update only Security Hotspots, issues will be updated in reaction to selectionChanged
updateSecurityHotspots()
if (currentIssuesPerOpenFile.isEmpty()) {
updateCurrentFileTab()
}
}

private fun updateSecurityHotspots() {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/sonarlint/intellij/ui/CurrentFilePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.swing.JScrollPane;
Expand Down Expand Up @@ -209,13 +210,14 @@ public <T extends Finding> void trySelectFilteredIssue(@Nullable LiveIssue issue
private void updateIcon(@Nullable VirtualFile file, Collection<LiveIssue> issues) {
var toolWindow = ToolWindowManager.getInstance(project).getToolWindow(SONARLINT_TOOLWINDOW_ID);
if (toolWindow != null) {
doUpdateIcon(file, issues, toolWindow);
var isEmpty = issues.stream().filter(i -> !i.isResolved()).collect(Collectors.toSet()).isEmpty();
doUpdateIcon(file, isEmpty, toolWindow);
}
}

private static void doUpdateIcon(@Nullable VirtualFile file, Collection<LiveIssue> issues, ToolWindow toolWindow) {
private static void doUpdateIcon(@Nullable VirtualFile file, boolean isEmpty, ToolWindow toolWindow) {
ApplicationManager.getApplication().assertIsDispatchThread();
boolean empty = file == null || issues.isEmpty();
boolean empty = file == null || isEmpty;
toolWindow.setIcon(empty ? SonarLintIcons.SONARQUBE_FOR_INTELLIJ_EMPTY_TOOLWINDOW : SonarLintIcons.SONARQUBE_FOR_INTELLIJ_TOOLWINDOW);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

<change-notes><![CDATA[
<ul>
<li>10.13.1 - Include a transparent and dark version of the plugin icon. Fix a noisy log error about a missing ProgressIndicator. Improve the tool window icon behavior to reflect the current number of issues in the file.</li>
<li>10.13 - SonarLint becomes SonarQube for IDE. Support for Standard and MQR mode. Fix an issue where the disk space used would grow indefinitely. Avoid an issue where the file system cache would run out of memory. Multiple performance improvements to the JS/TS analyzer. 7 new C++ rules and 1 new Security Hotspot C++ rule. Improve the tolerance to syntax errors when parsing Java switch expressions. Detection of secrets in PHP and C#. Support of Python 3.13. Deprecate the usage of Node.js 18 for JS/TS analysis. 1 new rule for Java. Support of more Java rules on test code. Bug fixes, fewer FPs and improvements for many languages.</li>
<li>10.12 - Support of Java 22 analysis. Automatically analyze opened files on remote environments. 2 new quick fixes for C++. Support for WindRiver GNU C++ compiler for arm. Improve analysis triggering performance. Many fixes on various graphical elements. Bug fixes, fewer FPs and improvements for many languages.</li>
<li>10.11.1 - Allow to open AI fix suggestions coming from SonarQube or SonarCloud. Avoid a rare issue when VFS is closed.</li>
Expand Down
7 changes: 3 additions & 4 deletions src/main/resources/META-INF/pluginIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/main/resources/META-INF/pluginIcon_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36b5c44

Please sign in to comment.