SLLS-547 fix: resolve 5 SonarQube deprecation and exception handling issues#709
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
SLLS-547 fix: resolve 5 SonarQube deprecation and exception handling issues#709sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
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)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




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. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/clientapi/SystemPropertiesAuthenticatorTest.java:51Why 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.
java:S1874 - Remove this use of "getPath"; it is deprecated. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:72Why 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::getPathmethod reference at line 72 with a lambdac -> Path.of(c.uri()).toString()that achieves the same result using the non-deprecateduri()method, eliminating the deprecated API usage warning.java:S1874 - Remove this use of "getPath"; it is deprecated. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:88Why 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::getPathmethod reference at line 88 withClientInputFile::uri, removing the use of the deprecatedgetPathmethod. The assertion tuple is also updated accordingly to match the new extraction (URI instead of path string), and the redundantClientInputFile::uriduplicate extraction at the end is removed.java:S1874 - Remove this use of "getPath"; it is deprecated. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/file/FolderFileSystemTests.java:120Why 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::getPathmethod reference at line 120 with a lambdaf -> Path.of(f.uri()).toString()that uses the non-deprecateduri()method instead, eliminating the deprecated API usage warning at that location.java:S1130 - Remove the declaration of thrown exception 'java.lang.InterruptedException', as it cannot be thrown from method's body. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java:55Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause 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 theprepare()method signature. This supports the fix for the code smell about declaring thrown exceptions that cannot actually be thrown from the method body.SonarQube Remediation Agent uses AI. Check for mistakes.