GithubHelp home page GithubHelp logo

Comments (6)

mebigfatguy avatar mebigfatguy commented on June 2, 2024

Yeah, that's an unfortunate false positive.

So lets see. Why is that a valid case. Well it's because you are not using the result of getText() again. So I guess really we should look to see if the thing that is being trimmed, and thrown away, is being used again.

What this would mean is that the trim() call is probably in a conditional expression, and doesn't show up again in the if or else of the conditional.

Ok, that seems right. Let's see what can be done.

from fb-contrib.

mebigfatguy avatar mebigfatguy commented on June 2, 2024

The issue is of course the trim() may be called on a string that is produced thru a long chain of methods, (yours is a chain, albeit not too long). Finding that pattern again is probably hard, which is probably why the FP exists today. Maybe it's good enough to look for the last method that produces the string to be trimmed, in this case, look for a call to WebElement.getText() regardless of what web element it was called on. sure that is broken too, but probably reduces the false positives to close to 0 (in exchange for a higher FN rate).

from fb-contrib.

ThrawnCA avatar ThrawnCA commented on June 2, 2024

Well, in this case, there's just a void method call and then return; is that a useful pattern for distinguishing false positives?

Maybe, if there is no further string access (no access to string variables, no method calls returning string) in one branch of the conditional, then it's considered legitimate? I guess that might still mask actual errors in the case where someone should have persisted the trimmed version, but didn't...although that should only matter for instance/static variables.

from fb-contrib.

mebigfatguy avatar mebigfatguy commented on June 2, 2024

yes that would be good enough to rule out, although, there would still be possible FPs. But that would be better.

from fb-contrib.

mebigfatguy avatar mebigfatguy commented on June 2, 2024

@ThrawnCA could you see if that resolves your issue?

from fb-contrib.

ThrawnCA avatar ThrawnCA commented on June 2, 2024

Well, it broke the FindBugs check, which is only enforced in the Maven build :D. But it was a deliberate thing (switch fall-through), so I just added a suppression annotation. The trim false positive is fixed :).

from fb-contrib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.