I have a number of occurrences in a new code base where there are a sequence of method calls like,
object o = something.foo();
bar(o);
something.foobar();
in consecutive lines. I would like to find / count the total number of such a sequence in my code where the name of object "something" could be different, but I want treated the same.
I want to pull these out as a method and see all the locations where this needs to be refactored. How do I go about doing something like this?
There are things that static analysis can't identify. For instance, static analysis can't detect whether software requirements have been fulfilled or how a function will execute. You'll need dynamic testing for that. That's why static analysis and dynamic testing are complementary.
SonarQube is the popular static analysis tool for continuously inspecting the code quality and security of your codebases and guiding development teams during code reviews. SonarQube is used for automated code review with CI/CD Integration.
Conclusions: Despite recent advances in methods for static code analysis, the state-of-the-art tools are not very effective in detecting security vulnerabilities.
Static code analysis, also known as Static Application Security Testing (SAST), is a vulnerability scanning methodology designed to work on source code rather than a compiled executable.
Intellij IDEA (incl. the free community version) does duplicated code detection & replacement.
If you carve out one of such occurrence into a method using its refactoring feature, it goes through the code base and asks you if you want to replace it in other places, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With