Details about the known misuse from the MUBench dataset.
| Description: | Calls a method on an object and later checks it for null.
|
| Fix Description: |
Move null-check to before first call.
|
| Violation Types: |
- misplaced/condition/null_check
|
| In File: | LateNullCheck.java |
| In Method: | misuse(Object) |
| Code with Misuse: |
class LateNullCheck {
public void misuse(Object o) {
o.hashCode();
if (o == null) {
o = new Object();
}
}
}
|
| Code with Pattern(s): |
public class NullGuard {
public void pattern(Object o) {
if (o == null) {
o = new Object();
}
o.hashCode();
}
}
|