mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Improve the inspection "Multiple occurrences of the same expression" (IDEA-207247)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class C {
|
||||
void test() {
|
||||
accept(n -> n * n);
|
||||
accept(n -> n * n);
|
||||
|
||||
accept(n -> {
|
||||
int a = <weak_warning descr="Multiple occurrences of 'n * n'">n * n</weak_warning>;
|
||||
int b = <weak_warning descr="Multiple occurrences of 'n * n'">n * n</weak_warning>;
|
||||
return a + b;
|
||||
});
|
||||
}
|
||||
|
||||
void accept(I i) {
|
||||
i.f(0);
|
||||
}
|
||||
|
||||
interface I {
|
||||
int f(int n);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
void test(int i, int j) {
|
||||
int a = <weak_warning descr="Multiple occurrences of 'Math.max(i, j)'">Math.max(i, j)</weak_warning>;
|
||||
int b = <weak_warning descr="Multiple occurrences of 'Math.max(i, j)'">Math.max(i, j)</weak_warning>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
void test() {
|
||||
double x = Math.random();
|
||||
double y = Math.random();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
void test() {
|
||||
double x = <weak_warning descr="Multiple occurrences of 'Math.sin(4)'">Math.sin(4)</weak_warning>;
|
||||
double y = <weak_warning descr="Multiple occurrences of 'Math.sin(4)'">Math.sin(4)</weak_warning>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class C {
|
||||
final int field;
|
||||
|
||||
C(int i) {
|
||||
field = i;
|
||||
}
|
||||
|
||||
void test(int param) {
|
||||
int a = field;
|
||||
int b = field;
|
||||
|
||||
int c = param;
|
||||
int d = param;
|
||||
|
||||
int e = <weak_warning descr="Multiple occurrences of 'field + param'">field + param</weak_warning>;
|
||||
int f = <weak_warning descr="Multiple occurrences of 'field + param'">field + param</weak_warning>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user