mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: more clear inspection messages
This commit is contained in:
+3
-1
@@ -877,7 +877,8 @@ fallthru.in.switch.statement.problem.descriptor=<code>#ref</code> fall-through i
|
||||
switch.statements.without.default.problem.descriptor=<code>#ref</code> statement without 'default' branch #loc
|
||||
default.not.last.case.in.switch.problem.descriptor=<code>#ref</code> branch not last case in 'switch' statement #loc
|
||||
loop.statements.that.dont.loop.problem.descriptor=<code>#ref</code> statement does not loop #loc
|
||||
conditional.expression.with.identical.branches.problem.descriptor=Conditional expression <code>#ref</code> with identical or similar branches #loc
|
||||
conditional.expression.with.identical.branches.problem.descriptor=Conditional expression <code>#ref</code> with identical branches #loc
|
||||
conditional.expression.with.similar.branches.problem.descriptor=Conditional expression <code>#ref</code> with similar branches #loc
|
||||
if.statement.with.identical.branches.problem.descriptor=<code>#ref</code> statement with identical branches #loc
|
||||
duplicate.condition.problem.descriptor=Duplicate condition <code>#ref</code> #loc
|
||||
duplicate.condition.ignore.method.calls.option=Ignore method calls in condition
|
||||
@@ -1148,6 +1149,7 @@ standard.variable.names.ignore.override.option=Ignore for parameter names identi
|
||||
static.variable.naming.convention.mutable.option=Check 'static final' fields with a mutable type
|
||||
boolean.method.name.must.start.with.question.table.column.name=Boolean method name prefix
|
||||
conditional.expression.with.identical.branches.collapse.quickfix=Collapse conditional expression
|
||||
conditional.expression.with.identical.branches.push.inside.quickfix=Push conditional inside expression
|
||||
conditional.expression.with.identical.branches.collapse.quickfix.family=Conditional expression can be simplified
|
||||
confusing.else.unwrap.quickfix=Remove redundant 'else'
|
||||
constant.conditional.expression.problem.descriptor=<code>#ref</code> can be simplified to ''{0}'' #loc
|
||||
|
||||
+9
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2016 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,10 @@ public class ConditionalExpressionWithIdenticalBranchesInspection extends BaseIn
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message("conditional.expression.with.identical.branches.problem.descriptor");
|
||||
final EquivalenceChecker.Decision decision = (EquivalenceChecker.Decision)infos[1];
|
||||
return InspectionGadgetsBundle.message(decision.isExact()
|
||||
? "conditional.expression.with.identical.branches.problem.descriptor"
|
||||
: "conditional.expression.with.similar.branches.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,9 +71,9 @@ public class ConditionalExpressionWithIdenticalBranchesInspection extends BaseIn
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message(getEquivalenceDecision().getExactlyMatches() ?
|
||||
"conditional.expression.with.identical.branches.collapse.quickfix" :
|
||||
"conditional.expression.with.identical.branches.collapse.quickfix.family") ;
|
||||
return InspectionGadgetsBundle.message(getEquivalenceDecision().getExactlyMatches()
|
||||
? "conditional.expression.with.identical.branches.collapse.quickfix"
|
||||
: "conditional.expression.with.identical.branches.push.inside.quickfix");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,7 +129,7 @@ public class ConditionalExpressionWithIdenticalBranchesInspection extends BaseIn
|
||||
final PsiExpression elseExpression = expression.getElseExpression();
|
||||
final EquivalenceChecker.Decision decision = EquivalenceChecker.expressionsAreEquivalentDecision(thenExpression, elseExpression);
|
||||
if (thenExpression != null && (myReportOnlyExactlyIdentical ? decision.getExactlyMatches() : !decision.isExactUnMatches())) {
|
||||
registerError(expression, expression);
|
||||
registerError(expression, expression, decision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -5,7 +5,7 @@ import java.util.Random;
|
||||
class ConditionalExpressionWithIdenticalBranches {
|
||||
|
||||
int one(boolean b) {
|
||||
return <warning descr="Conditional expression 'b ? 1 + 2 + 3 : 1 + 2 + 3' with identical or similar branches">b ? 1 + 2 + 3 : 1 + 2 + 3</warning>;
|
||||
return <warning descr="Conditional expression 'b ? 1 + 2 + 3 : 1 + 2 + 3' with identical branches">b ? 1 + 2 + 3 : 1 + 2 + 3</warning>;
|
||||
}
|
||||
|
||||
int two(boolean b) {
|
||||
@@ -13,7 +13,7 @@ class ConditionalExpressionWithIdenticalBranches {
|
||||
}
|
||||
|
||||
Class<String> three(boolean b) {
|
||||
return <warning descr="Conditional expression 'b ? java.lang.String.class : String.class' with identical or similar branches">b ? java.lang.String.class : String.class</warning>;
|
||||
return <warning descr="Conditional expression 'b ? java.lang.String.class : String.class' with identical branches">b ? java.lang.String.class : String.class</warning>;
|
||||
}
|
||||
|
||||
int incomplete(boolean b) {
|
||||
@@ -21,27 +21,27 @@ class ConditionalExpressionWithIdenticalBranches {
|
||||
}
|
||||
|
||||
void fuzzy() {
|
||||
String someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? \"2\" + \"q\" + \"1\" : \"2\" + \"qwe\" + \"1\"' with identical or similar branches">new Random().nextBoolean() ? "2" + "q" + "1" : "2" + "qwe" + "1"</warning>;
|
||||
String someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? \"2\" + \"q\" + \"1\" : \"2\" + \"qwe\" + \"1\"' with similar branches">new Random().nextBoolean() ? "2" + "q" + "1" : "2" + "qwe" + "1"</warning>;
|
||||
}
|
||||
|
||||
void fuzzy2() {
|
||||
Object someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? (Object) \"1\" : (Object) \"2\"' with identical or similar branches">new Random().nextBoolean() ? (Object) "1" : (Object) "2"</warning>;
|
||||
Object someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? (Object) \"1\" : (Object) \"2\"' with similar branches">new Random().nextBoolean() ? (Object) "1" : (Object) "2"</warning>;
|
||||
}
|
||||
|
||||
void fuzzy3() {
|
||||
Object someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? \"21\" + (Object) \"1\" : \"21\" + (Object) \"2\"' with identical or similar branches">new Random().nextBoolean() ? "21" + (Object) "1" : "21" + (Object) "2"</warning>;
|
||||
Object someString = <warning descr="Conditional expression 'new Random().nextBoolean() ? \"21\" + (Object) \"1\" : \"21\" + (Object) \"2\"' with similar branches">new Random().nextBoolean() ? "21" + (Object) "1" : "21" + (Object) "2"</warning>;
|
||||
}
|
||||
|
||||
void fuzzy4(int[] ints) {
|
||||
int i = <warning descr="Conditional expression 'new Random().nextBoolean() ? ints[3] : ints[4]' with identical or similar branches">new Random().nextBoolean() ? ints[3] : ints[4]</warning>;
|
||||
int i = <warning descr="Conditional expression 'new Random().nextBoolean() ? ints[3] : ints[4]' with similar branches">new Random().nextBoolean() ? ints[3] : ints[4]</warning>;
|
||||
}
|
||||
|
||||
void fuzzy5(String[] strings) {
|
||||
String s = <warning descr="Conditional expression 'new Random().nextBoolean()? \"asd\" + strings[2] : \"qwe\" + strings[2]' with identical or similar branches">new Random().nextBoolean()? "asd" + strings[2] : "qwe" + strings[2]</warning>;
|
||||
String s = <warning descr="Conditional expression 'new Random().nextBoolean()? \"asd\" + strings[2] : \"qwe\" + strings[2]' with similar branches">new Random().nextBoolean()? "asd" + strings[2] : "qwe" + strings[2]</warning>;
|
||||
}
|
||||
|
||||
void fuzzy6() {
|
||||
int j = <warning descr="Conditional expression 'new Random().nextBoolean() ? 6 + someMethod(\"123\", \"\") : 6 + someMethod(\"321\", \"\")' with identical or similar branches">new Random().nextBoolean() ? 6 + someMethod("123", "") : 6 + someMethod("321", "")</warning>;
|
||||
int j = <warning descr="Conditional expression 'new Random().nextBoolean() ? 6 + someMethod(\"123\", \"\") : 6 + someMethod(\"321\", \"\")' with similar branches">new Random().nextBoolean() ? 6 + someMethod("123", "") : 6 + someMethod("321", "")</warning>;
|
||||
}
|
||||
|
||||
int someMethod(String s, String s2) {
|
||||
@@ -59,7 +59,7 @@ class ConditionalExpressionWithIdenticalBranches {
|
||||
int i = 1;
|
||||
Item item = (i == 1 ? new Item("1") : new Item(i)); // warning here
|
||||
|
||||
Item item1 = (<warning descr="Conditional expression 'i == 1 ? new Item(\"1\") : new Item(\"2\")' with identical or similar branches">i == 1 ? new Item("1") : new Item("2")</warning>); // warning here
|
||||
Item item1 = (<warning descr="Conditional expression 'i == 1 ? new Item(\"1\") : new Item(\"2\")' with similar branches">i == 1 ? new Item("1") : new Item("2")</warning>); // warning here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user