Skip to content

SONARJAVA-6801 Remove redundant fully qualified names in TransactionalMethodCheckedExceptionCheck - #5933

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260818-050237-13c669be
Open

SONARJAVA-6801 Remove redundant fully qualified names in TransactionalMethodCheckedExceptionCheck#5933
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260818-050237-13c669be

Conversation

@sonarqube-agent

Copy link
Copy Markdown

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

Why these issues? Both SonarQube issues target the same rule (java:S1942) in the same file and involve straightforward import qualification fixes. The changes are well-scoped, actionable, and can be confidently applied, making them suitable for a single focused PR that improves code consistency and eliminates minor code smell violations.

Replace unnecessary fully qualified class names with their simple names in TransactionalMethodCheckedExceptionCheck.java, since AssignmentExpressionTree and IdentifierTree are already imported in the file. This eliminates code smell violations and improves code readability by using consistent import-based references.

View Project in SonarCloud


Fixed Issues

java:S1942 - Replace this fully qualified name with "AssignmentExpressionTree" • MINORView issue 1
java:S1942 - Replace this fully qualified name with "IdentifierTree" • MINORView issue 2

Location: java:java-checks/src/main/java/org/sonar/java/checks/spring/TransactionalMethodCheckedExceptionCheck.java:266

Why is this an issue?

Java’s import mechanism allows the use of simple class names. Therefore, using a class' fully qualified name in a file that imports the class is redundant and confusing.

What changed

This hunk replaces fully qualified class names with their simple names. Specifically, it changes org.sonar.plugins.java.api.tree.AssignmentExpressionTree to AssignmentExpressionTree and org.sonar.plugins.java.api.tree.IdentifierTree to IdentifierTree. Since these classes are already imported in the file, using their fully qualified names is redundant and confusing. This directly fixes the code smell warning about the redundant fully qualified name for AssignmentExpressionTree on line 266, as well as the code smell warning about the redundant fully qualified name for IdentifierTree on line 267. Both replacements use the simple class names that are available through the file's existing imports.

--- a/java-checks/src/main/java/org/sonar/java/checks/spring/TransactionalMethodCheckedExceptionCheck.java
+++ b/java-checks/src/main/java/org/sonar/java/checks/spring/TransactionalMethodCheckedExceptionCheck.java
@@ -266,2 +266,2 @@ public class TransactionalMethodCheckedExceptionCheck extends IssuableSubscripti
-          var assignment = (org.sonar.plugins.java.api.tree.AssignmentExpressionTree) arg;
-          String name = ((org.sonar.plugins.java.api.tree.IdentifierTree) assignment.variable()).name();
+          var assignment = (AssignmentExpressionTree) arg;
+          String name = ((IdentifierTree) assignment.variable()).name();

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AaATHsqG8ziIV05gbeJS for java:S1942 rule
- AaATHsqG8ziIV05gbeJT for java:S1942 rule

Generated by SonarQube Agent (task: 33c62758-3516-4e0d-b01b-90e55202f06f)
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Remove redundant fully qualified names in TransactionalMethodCheckedExceptionCheck SONARJAVA-6801 Remove redundant fully qualified names in TransactionalMethodCheckedExceptionCheck Aug 19, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-6801

@sonarqube-next

Copy link
Copy Markdown
Contributor

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.

2 participants