SLLS-548 fix: resolve 6 SonarQube code quality issues#710
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
SLLS-548 fix: resolve 6 SonarQube code quality issues#710sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZjr5wG89TChwHguyc6z for java:S1874 rule - AZmEP12ibmPIH7Bq_J8m for java:S1874 rule - AZmEP12ibmPIH7Bq_J8n for java:S1874 rule - AZmEP12ibmPIH7Bq_J8o for java:S1874 rule - AZjRjd_I592amupb0FQS for java:S135 rule - AZjRjd5M592amupb0FPm for java:S3008 rule Generated by SonarQube Agent (task: adc7064c-18ef-4014-a33b-57cf41daf851)
|
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 URL constructors with URI.create().toURL(), fixes static field naming conventions to use camelCase, adds missing import for Paths, and refactors a loop to eliminate multiple break/continue statements. These changes improve code quality and align with 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/SonarLintVSCodeClientTests.java:267Why 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
Removes the import of the deprecated
java.net.URLclass. Since all three usages of the deprecatednew URL(...)constructor are being replaced withURI.create(...).toURL(), the direct import ofjava.net.URLis no longer needed. This supports the fix for all three deprecation warnings about using the deprecatedURLconstructor.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/SonarLintVSCodeClientTests.java:875Why 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
Removes the import of the deprecated
java.net.URLclass. Since all three usages of the deprecatednew URL(...)constructor are being replaced withURI.create(...).toURL(), the direct import ofjava.net.URLis no longer needed. This supports the fix for all three deprecation warnings about using the deprecatedURLconstructor.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/SonarLintVSCodeClientTests.java:890Why 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
Removes the import of the deprecated
java.net.URLclass. Since all three usages of the deprecatednew URL(...)constructor are being replaced withURI.create(...).toURL(), the direct import ofjava.net.URLis no longer needed. This supports the fix for all three deprecation warnings about using the deprecatedURLconstructor.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:104Why 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.nio.file.Paths, which is needed by the replacement code in Hunk 2 that replaces the deprecatedClientInputFile::getPathmethod reference withPaths.get(f.uri()).toString().java:S3008 - Rename this field "MODULE_1_ROOT_URI" to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/JavaMediumTests.java:54Why is this an issue?
The Java Language Specification defines a set of rules called naming conventions that apply to Java programs. These conventions provide recommendations for naming packages, classes, methods, and variables.
What changed
This hunk directly fixes the naming convention violation by renaming the static non-final fields
MODULE_1_ROOT_URIandMODULE_2_ROOT_URItomodule1RootUriandmodule2RootUri, which match the required camelCase pattern^[a-z][a-zA-Z0-9]*$. This is the core fix for the static field naming convention code smell.java:S135 - Reduce the total number of break and continue statements in this loop to use at most one. • MINOR • View issue
Location:
sonarlint-language-server:src/main/java/org/sonarsource/sonarlint/ls/java/JavaSdkUtil.java:69Why is this an issue?
The use of
breakandcontinuestatements increases the complexity of the control flow and makes it harder to understand the program logic. In order to keep a good program structure, they should not be applied more than once per loop.What changed
This hunk restructures the loop body to eliminate the first 'continue' statement by inverting the condition. Instead of checking if the jar file is an alternative implementation and continuing (skipping), it now checks if the jar file is NOT an alternative implementation and performs the work inside a nested if-block. The logic that was previously after the two continue statements is now nested inside this condition, combining both filter checks into a single nested structure without any continue statements.
SonarQube Remediation Agent uses AI. Check for mistakes.