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

UselessCode FP #91

Open
mebigfatguy opened this issue Dec 23, 2016 · 1 comment
Open

UselessCode FP #91

mebigfatguy opened this issue Dec 23, 2016 · 1 comment
Labels

Comments

@mebigfatguy
Copy link
Contributor

the useless code detector fires when a condition is known only from an assert. It should ignore asserts as pre-conditions.

ie

       assert cmp <= 0;

        if (cmp < 0)
        {
            break; 
        }
        else if (cmp == 0)   // <-- UC Fires here
        {
             ....
        }
@jsotuyod jsotuyod added the bug label Dec 23, 2016
KengoTODA added a commit to KengoTODA/spotbugs that referenced this issue Feb 4, 2017
KengoTODA added a commit to KengoTODA/spotbugs that referenced this issue Feb 4, 2017
KengoTODA added a commit to KengoTODA/spotbugs that referenced this issue Feb 5, 2017
KengoTODA added a commit to KengoTODA/spotbugs that referenced this issue Feb 5, 2017
… to ignore assert

but this approach failed due to AnalysisCache problem:
that cache expect that we have only one CFG for each descriptor
so this branch has failed tests like below:

```
  Error pruning normal return edges for unconditionally throwing methods for UselessCode.method(I)V
    edu.umd.cs.findbugs.ba.DataflowAnalysisException: not enough values on stack: access=1, avail=0
      At edu.umd.cs.findbugs.ba.Frame.getStackValue(Frame.java:247)
```
@Maaartinus
Copy link

I slightly disagree.

With assert, two versions of the code to be analyzed at the same time. When something makes sense in either version, then it's not redundant.

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

No branches or pull requests

3 participants