Reputation: 58772
We found a bug in old code which could be easily found if there would be a warning,
The issue was that inner class member was used but not assigned or initialized. Sample code minimized. Problem is that url
is always null.
public class Main {
public class Sender {
private String url;
public Sender() {
}
public void send() {
OtherClass.send(url);
}
}
}
In intellij it warns about variable never assigned. In eclipse I didn't find such warning.
The code is more complex and adding a warning at any level will reduce time to find similar bugs.
Is it possible in eclipse to warn in some way if variable is used before assigned/initialized ?
Upvotes: 1
Views: 102
Reputation: 7948
You can use SpotBugs(successor of findbugs) eclipse plugin. Right click on project Spotbugs->find bugs this will find these types of bugs.
I suggest also installing sonarlint plugin which has good static analysis capabilities.
https://marketplace.eclipse.org/content/spotbugs-eclipse-plugin
https://marketplace.eclipse.org/content/sonarlint
Upvotes: 2