) element)::compareTo; // no violation
+
+ Bean bean = new Bean();
+ assertEquals(1, ((int[]) bean.array)[0]); // no violation
+
+ // violation below 'Unnecessary parentheses around expression.'
+ float rest = ((float) (50 - System.currentTimeMillis())) / 1000;
+ float stop = (float) (50 - System.currentTimeMillis()) / 1000;
+
+ // no violation below as parentheses detection in ternary(?) operators
+ // is handled by different logic and is dependent on QUESION token
+ float pin = false ? ((float) 21) : ((float) 31);
+
+ Object obj = "hello"; // no violation below
+ String result1 = (obj instanceof String) ? ((String) obj) : "Default";
+
+ String op1 = ((String) obj) + ((Boolean) finished).toString();
+ // violation above 'Unnecessary parentheses around expression.'
+ String op2 = (String) obj + ((Boolean) finished).toString();
+
+ filevalue = "'" + ((char) 32) + "'";
+ // violation above 'Unnecessary parentheses around expression.'
+ filevalue = "'" + (char) 31 + "'"; // no violation
+
+ ck("name", (long) k, (long) ((byte) 0x22));
+ // violation above 'Unnecessary parentheses around expression.'
+ ck("check", (long) k, (long) (byte) 0x24);
+ }
+
+ public void ck(String byt, long a, long c) {}
+ static class T {}
+ public class Bean {
+ public Object array;
+ public Bean() {
+ array = new int[]{1, 2, 3};
+ }
+ }
+}
diff --git a/src/xdocs/checks/coding/unnecessaryparentheses.xml b/src/xdocs/checks/coding/unnecessaryparentheses.xml
index c380ee723a4..df1df3f31b0 100644
--- a/src/xdocs/checks/coding/unnecessaryparentheses.xml
+++ b/src/xdocs/checks/coding/unnecessaryparentheses.xml
@@ -179,6 +179,8 @@ if ((++f) > g && a) { // violation, unnecessary paren
BAND
,
QUESTION
+ ,
+ TYPECAST
.
@@ -264,6 +266,8 @@ if ((++f) > g && a) { // violation, unnecessary paren
POST_INC
,
POST_DEC
+ ,
+ TYPECAST
.
|
3.4 |