SLLS-545 fix: resolve 5 SonarQube code style violations in tests#707
Closed
sonarqube-agent[bot] wants to merge 1 commit into
Closed
SLLS-545 fix: resolve 5 SonarQube code style violations in tests#707sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZjRjd54592amupb0FPu for java:S1481 rule - AZjRjd7G592amupb0FP7 for java:S116 rule - AZjRjdx3592amupb0FPP for java:S117 rule - AZjRjduY592amupb0FPF for java:S1130 rule - AZjRjduY592amupb0FPD for java:S116 rule Generated by SonarQube Agent (task: c702df97-7b4b-4e29-a108-fbe171892d7e)
Summary
This PR fixes 5 MINOR SonarQube violations in test files by renaming 3 fields/variables to comply with Java camelCase conventions, removing a superfluous exception declaration, and deleting an unused variable. All changes are purely stylistic with no functional impact. As a bonus, indentation in a Go code string literal is corrected. Changes span 4 test files:
What reviewers should knowReviewer checklist:
Quick navigation:
|
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.
Fixed 5 MINOR SonarQube issues including renaming fields and local variables to comply with Java naming conventions, removing an unused variable, and eliminating a superfluous exception declaration. These changes improve code quality and consistency with established Java coding standards.
View Project in SonarCloud
Fixed Issues
java:S116 - Rename this field "LOG" to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/testutils/SonarLintLogTester.java:75Why is this an issue?
A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
What changed
Renames the field 'LOG' to 'log' to comply with the Java naming convention that field names should match the pattern '^[a-z][a-zA-Z0-9]*$'. The original uppercase name 'LOG' violated this convention as it didn't start with a lowercase letter.
java:S116 - Rename this field "FILE_PYTHON" 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/commands/ShowAllLocationsCommandTests.java:52Why is this an issue?
A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
What changed
Renames the field
FILE_PYTHONtofilePythonto match the naming convention pattern^[a-z][a-zA-Z0-9]*$. The original name used uppercase with underscores (constant-style naming), which violates the field naming convention for non-static fields.java:S1130 - Remove the declaration of thrown exception 'java.util.concurrent.ExecutionException', 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 import of
java.util.concurrent.ExecutionException, which is no longer needed after removing the superfluousExecutionExceptionfrom thethrowsclause of theprepare()method. This supports the fix for the code smell about declaring a thrown exception that cannot actually be thrown from the method's body.java:S1481 - Remove this unused "fakeNotebook" local variable. • MINOR • View issue
Location:
sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/notebooks/OpenNotebooksCacheTests.java:68Why is this an issue?
An unused local variable is a variable that has been declared but is not used anywhere in the block of code where it is defined. It is dead code, contributing to unnecessary complexity and leading to confusion when reading the code. Therefore, it should be removed from your code to maintain clarity and efficiency.
What changed
Removes the unused local variable 'fakeNotebook' which was declared and assigned but never used anywhere in the test method. This directly addresses the code smell about unnecessary local variables that add complexity and reduce readability.
java:S117 - Rename this local variable 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/LanguageServerMediumTests.java:958Why is this an issue?
A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
Local variables and method parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily recognizable pattern.
Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to maintain and debug. It also ensures consistency in the code, especially when multiple developers are working on the same project.
What changed
This hunk renames the local variables 'OLD' and 'NEW' to 'oldValue' and 'newValue', respectively. The original names 'OLD' and 'NEW' are uppercase, which violates the naming convention rule requiring local variables to match the pattern '^[a-z][a-zA-Z0-9]*$'. The new names follow camelCase convention and satisfy the required regular expression.
SonarQube Remediation Agent uses AI. Check for mistakes.