aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses/InputUnnecessaryParenthesesOperatorsAndCasts.java
blob: 777f4b15e5b63f21b8a1f33e06890d507a369c67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.puppycrawl.tools.checkstyle.checks.coding.unnecessaryparentheses;
public class InputUnnecessaryParenthesesOperatorsAndCasts {
    int f1() {
        int x = 0;
        for (int i = (0+1); ((i) < (6+6)); i += (1+0)) {
            x += (i + 100);
            (x) += (i + 100/**comment test*/);
            x = (x + i + 100);
            (x) = (x + i + 100);
        }

        for (int i = (0+1); (i) < ((6+6)); i += (1+0)) {
            System.identityHashCode("hi");
        }

        return (0);
    }

    private int f2(int arg1, double arg2) {
        int x, a, b, c, d;
        String e, f;

        x = 0;
        a = 0;
        b = 0;
        c = (a + b);
        d = c - 1;

        int i = (int) arg2;
        i = ((int) arg2);

        x += (i + 100 + arg1);
        a = (a + b) * (c + d);
        b = ((((a + b) * (c + d))));
        c = (((a) <= b)) ? 0 : 1;
        d = (a) + (b) * (600) / (int) (12.5f) + (int) (arg2);
        e = ("this") + ("that") + ("is" + "other");
        f = ("this is a really, really long string that should be truncated.");

        return (x + a + b + d);
    }

    private boolean f3() {
        int x = f2((1), (13.5));
        boolean b = (true);
        return (b);
    }

    public static int f4(int z, int a) {
        int r = (z * a);
        r = (a > z) ? a : z;
        r = ((a > z) ? a : z);
        r = (a > z) ? a : (z + z);
        return (r * r - 1);
    }

    public void f5() {
        int x, y;
        x = 0;
        y = 0;
        if (x == y) {
            print(x);
        }
        if ((x > y)) {
            print(y);
        }

        while ((x < 10)) {
            print(x++);
        }

        do {
            print((y+=100));
        } while (y < (4000));
    }

    private void f6(TypeA a) {
        TypeB b = (TypeB) a;
        TypeC c = ((TypeC) a);
        int r = 12345;
        r <<= (3);
        TypeParameterized<String> d = ((TypeParameterized<String>) a);
    }

    private void print(int arg)
    {
        System.identityHashCode("arg = " + arg);
    }

    static class TypeParameterized<T> {}
    static class TypeA extends TypeParameterized<String> {}
    static class TypeB extends TypeA {}
    static class TypeC extends TypeA {}
}