You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
When upgrading to 6.52.0 (from 6.51.0), this incorrectly flagged a caught exception that was returned. This is certainly not the nicest code or a good style, but was necessary for conforming to a service provider's interface. If not for constraints and being one-off code, a Try data type have been a nicer abstraction for this case, but I digress.
Code Sample demonstrating the issue:
A simplified version of the code that flags e as unnecessary.
adangel
changed the title
UnnecessaryLocalBeforeReturn - false positive with catch clause
[java] UnnecessaryLocalBeforeReturn - false positive with catch clause
Jan 19, 2023
Affects PMD Version:
Rule:
UnnecessaryLocalBeforeReturn: Consider simply returning the value vs storing it in local variable 'e'
Description:
When upgrading to
6.52.0
(from 6.51.0), this incorrectly flagged a caught exception that was returned. This is certainly not the nicest code or a good style, but was necessary for conforming to a service provider's interface. If not for constraints and being one-off code, a Try data type have been a nicer abstraction for this case, but I digress.Code Sample demonstrating the issue:
A simplified version of the code that flags
e
as unnecessary.Expected outcome:
PMD reports a violation at line return e, but that's wrong. That's a false positive.
Running PMD through: Gradle
The text was updated successfully, but these errors were encountered: