4

Is there a freely available static code analysis tool for Java, which can detect that I use the same constant value as method argument on all calls to a method, so I can remove the argument and use a constant value inside the method body? E.g. in

class A {
    void methodA {
        someMethod("first", 42);
    }
}

class B {
    void methodB {
        someMethod("second", 42);
    }
    void methodC {
        someMethod("third", 42);
    }
}

I want to have the second argument of someMethod to be reported (given that these 3 calls are all calls to that method in my project).

I found no such thing in the Eclipse compiler warnings, Findbugs, CodePro Analytix or UCDetector, but I may have missed the corresponding setting.

EDIT: Just to make sure: I'm not asking for how to remove the constant value by refactorings. I'm asking for how to detect this situation, given that those 3 method invocations might be spread over some thousand source files.

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88

1 Answers1

0

I guess you can try to use Sonar: http://www.sonarsource.org/

dstronczak
  • 2,406
  • 4
  • 28
  • 41