mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java: Detect trivial duplicates containing conditional 'return' (IDEA-182195)
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NullableCheckVoidDuplicate {
|
||||
void foo() {
|
||||
Object o = newMethod();
|
||||
if (o == null) return;
|
||||
System.out.println(o);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object newMethod() {
|
||||
Object o = "";
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i == 10) {
|
||||
o = null;
|
||||
}
|
||||
}
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
void bar() {
|
||||
Object o = newMethod();
|
||||
if (o == null) return;
|
||||
System.out.println(o);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user