Skip to content

SLLS-547 fix: resolve 5 SonarQube deprecation and exception handling issues#709

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260523-050236-c43447ae
Open

SLLS-547 fix: resolve 5 SonarQube deprecation and exception handling issues#709
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260523-050236-c43447ae

Conversation

@sonarqube-agent
Copy link
Copy Markdown
Contributor

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Replaces deprecated API usages (URL, getPath) with their modern equivalents (URI, uri()) and removes unnecessary exception declarations in test files. These changes eliminate SonarQube code smell warnings and improve code quality by using current Java best practices.

View Project in SonarCloud


Fixed Issues

java:S1874 - Remove this use of "URL"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/clientapi/SystemPropertiesAuthenticatorTest.java:51

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the import for java.net.URI, which is needed by the fix in Hunk 2 that replaces the deprecated URL constructor with URI(...).toURL(). Without this import, the new URI usage would not compile.

--- a/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SystemPropertiesAuthenticatorTest.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/clientapi/SystemPropertiesAuthenticatorTest.java
@@ -22,0 +23,1 @@ import java.net.Authenticator;
+import java.net.URI;
java:S1874 - Remove this use of "getPath"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:72

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Replaces the deprecated ClientInputFile::getPath method reference at line 72 with a lambda c -> Path.of(c.uri()).toString() that achieves the same result using the non-deprecated uri() method, eliminating the deprecated API usage warning.

--- a/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
@@ -72,1 +72,1 @@ class FolderFileSystemTests {
-      .extracting(ClientInputFile::getPath, FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
+      .extracting(c -> Path.of(c.uri()).toString(), FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
java:S1874 - Remove this use of "getPath"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:88

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Replaces the deprecated ClientInputFile::getPath method reference at line 88 with ClientInputFile::uri, removing the use of the deprecated getPath method. The assertion tuple is also updated accordingly to match the new extraction (URI instead of path string), and the redundant ClientInputFile::uri duplicate extraction at the end is removed.

--- a/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
@@ -88,3 +88,3 @@ class FolderFileSystemTests {
-      .extracting(ClientInputFile::getPath, FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
-        ClientInputFile::relativePath, ClientInputFile::uri)
-      .containsExactly(tuple(pythonFile.toAbsolutePath().toString(), "", true, StandardCharsets.UTF_8, pythonFile.toUri(), "file.py", pythonFile.toUri()));
+      .extracting(ClientInputFile::uri, FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
+        ClientInputFile::relativePath)
+      .containsExactly(tuple(pythonFile.toUri(), "", true, StandardCharsets.UTF_8, pythonFile.toUri(), "file.py"));
java:S1874 - Remove this use of "getPath"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:120

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Replaces the deprecated ClientInputFile::getPath method reference at line 120 with a lambda f -> Path.of(f.uri()).toString() that uses the non-deprecated uri() method instead, eliminating the deprecated API usage warning at that location.

--- a/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java
@@ -120,1 +120,1 @@ class FolderFileSystemTests {
-      .extracting(ClientInputFile::getPath, FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
+      .extracting(f -> Path.of(f.uri()).toString(), FolderFileSystemTests::getFileContents, ClientInputFile::isTest, ClientInputFile::getCharset, ClientInputFile::getClientObject,
java:S1130 - Remove the declaration of thrown exception 'java.lang.InterruptedException', as it cannot be thrown from method's body. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java:55

Why is this an issue?

Superfluous exceptions within throws clauses have negative effects on the readability and maintainability of the code. An exception in a throws clause is superfluous if it is:

What changed

Removes the unused import of java.util.concurrent.ExecutionException, which is no longer needed after removing the superfluous exception declarations from the prepare() method signature. This supports the fix for the code smell about declaring thrown exceptions that cannot actually be thrown from the method body.

--- a/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
@@ -27,1 +26,0 @@ import java.util.List;
-import java.util.concurrent.ExecutionException;

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZjRjduY592amupb0FPG for java:S1130 rule
- AZmEP142bmPIH7Bq_J8p for java:S1874 rule
- AZjr5wG89TChwHguyc60 for java:S1874 rule
- AZjr5wG89TChwHguyc6x for java:S1874 rule
- AZjr5wG89TChwHguyc6y for java:S1874 rule

Generated by SonarQube Agent (task: 4deeb420-9b4e-4c3f-8837-89ba2378e617)
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title fix: resolve 5 SonarQube deprecation and exception handling issues SLLS-547 fix: resolve 5 SonarQube deprecation and exception handling issues May 23, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 23, 2026

SLLS-547

@sonarqube-next
Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
1 New issue

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants