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

[java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block #4063

Closed
LynnBroe opened this issue Jul 25, 2022 · 0 comments · Fixed by #4533
Closed

[java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block #4063

LynnBroe opened this issue Jul 25, 2022 · 0 comments · Fixed by #4533
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@LynnBroe
Copy link
Contributor

LynnBroe commented Jul 25, 2022

Affects PMD Version:

Rule: AvoidBranchingStatementAsLastInLoop

Description:

Code A: PMD report Avoidbranchingstatementaslastinloop error at line 11

while (true) {
  try {
    // nothing to do
  }
  catch (Throwable c) {
    throw c;
  }
  break; // violation here
}

Code B: transform the code,then the PMD doesn't report any error

while (true) {
  try {
    // nothing to do
  }
  catch (Throwable c) {
    throw c;
  }
  finally {
    break; // missing violation
  }
}

Running PMD through: CLI

@LynnBroe LynnBroe added the a:false-negative PMD doesn't flag a problematic piece of code label Jul 25, 2022
@LynnBroe LynnBroe changed the title False-negative about try/catch block in Loop [java]False-negative about try/catch block in Loop May 3, 2023
@adangel adangel changed the title [java]False-negative about try/catch block in Loop [java] AvoidBranchingStatementAsLastInLoop: False-negative about try/catch block May 19, 2023
@adangel adangel changed the title [java] AvoidBranchingStatementAsLastInLoop: False-negative about try/catch block [java] AvoidBranchingStatementAsLastInLoop: False-negative about try/finally block May 19, 2023
@adangel adangel added this to the 7.0.0 milestone May 19, 2023
adangel added a commit to adangel/pmd that referenced this issue May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants