Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAS_BLOATED_ASSIGNMENT_SCOPE: strange violations that hard to understand #475

Open
romani opened this issue Oct 4, 2024 · 1 comment
Open

Comments

@romani
Copy link

romani commented Oct 4, 2024

detected checkstyle/checkstyle#15725 (comment)
Bumps com.mebigfatguy.sb-contrib:sb-contrib from 7.6.4 to 7.6.5.

[ERROR] Medium: Method com.puppycrawl.tools.checkstyle.checks.coding
.UnusedCatchParameterShouldBeUnnamedCheck.isCatchParameterIdentifierCandidate(DetailAST)
 assigns a variable in a larger scope than is needed 
[com.puppycrawl.tools.checkstyle.checks.coding.UnusedCatchParameterShouldBeUnnamedCheck] 
At UnusedCatchParameterShouldBeUnnamedCheck.java:[line 164]
 BAS_BLOATED_ASSIGNMENT_SCOPE

[ERROR] Medium: Method com.puppycrawl.tools.checkstyle.checks.coding
.UnusedCatchParameterShouldBeUnnamedCheck.isCatchParameterIdentifierCandidate(DetailAST) 
assigns a variable in a larger scope than is needed 
[com.puppycrawl.tools.checkstyle.checks.coding.UnusedCatchParameterShouldBeUnnamedCheck] 
At UnusedCatchParameterShouldBeUnnamedCheck.java:[line 166]
 BAS_BLOATED_ASSIGNMENT_SCOPE

[ERROR] Medium: Method com.puppycrawl.tools.checkstyle.checks.imports
.PkgImportControl.matchesAtFrontNoRegex(String) 
assigns a variable in a larger scope than is needed
 [com.puppycrawl.tools.checkstyle.checks.imports.PkgImportControl] At PkgImportControl.java:[line 245] 
BAS_BLOATED_ASSIGNMENT_SCOPE

looks like false positives

@mebigfatguy
Copy link
Owner

it's a relatively cheesy report, but in the first case

UnusedCatchParameterShouldBeUnnamedCheck.java:[line 164]

for example

you could do at 162

if (isCatchParameterDeclaration) {
return false;
}

and then line 168 becomes

return (hasValidParentToken || isMethodInvocation);

which avoids the execution of some code if isCatchParameterDeclaration is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants