I have a class field which is a data object. Why does checkstyle complain about "write occurrence of b" and what does it mean ? The doSomething1() is always called before doSomething()
public class A{
private B b;
public void doSomething() {
if(b!=null) {
b.setYear(2012);
b.setDay("Tuesday");
}
}
public void doSomething1(){
b = new B();
b.setDate(new Date());
}
}
It is not Checkstyle that this is coming from, but Eclipse itself.
If you highlight a property of your class, it will show you occurrences of that property in the class, with markers in the right-hand scroll bar. These are yellow, like the Checkstyle markers.
It will highlight instances where the property is read ("Occurrence of X") and where that property could be written to ("Write occurence of X"), for instance if you pass it into a method as a parameter.
You can see where the message is configured http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.5.2/org.eclipse.jdt/ui/3.5.2/org/eclipse/jdt/internal/ui/search/SearchMessages.properties
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