mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
make IG test light
This commit is contained in:
+73
@@ -0,0 +1,73 @@
|
||||
package com.siyeh.igtest.bitwise.pointless_bitwise_expression;
|
||||
|
||||
public class PointlessBitwiseExpression {
|
||||
private static final int ZERO = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
final int i = 1;
|
||||
int j = <warning descr="'i & 0' can be replaced with '0'">i & 0</warning>;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = <warning descr="'j | 0' can be replaced with 'j'">j | 0</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'j ^ 0' can be replaced with 'j'">j ^ 0</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'j << 0' can be replaced with 'j'">j << 0</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'j >> 0' can be replaced with 'j'">j >> 0</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'j >>> 0' can be replaced with 'j'">j >>> 0</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'j >>> ZERO' can be replaced with 'j'">j >>> ZERO</warning>;
|
||||
System.out.println(k);
|
||||
}
|
||||
|
||||
public static void main3(String[] args) {
|
||||
final int i = 1;
|
||||
int j = <warning descr="'0 & i' can be replaced with '0'">0 & i</warning>;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = <warning descr="'0 | j' can be replaced with 'j'">0 | j</warning>;
|
||||
System.out.println(k);
|
||||
k = <warning descr="'0 ^ j' can be replaced with 'j'">0 ^ j</warning>;
|
||||
System.out.println(k);
|
||||
|
||||
}
|
||||
|
||||
public static void main2(String[] args) {
|
||||
final int i = 1;
|
||||
int j = <warning descr="'i & 0xffffffff' can be replaced with 'i'">i & 0xffffffff</warning>;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = <warning descr="'j | 0xffffffff' can be replaced with '0xffffffff'">j | 0xffffffff</warning>;
|
||||
System.out.println(k);
|
||||
j = 6;
|
||||
k = <warning descr="'j ^ 0xffffffff' can be replaced with '~j'">j ^ 0xffffffff</warning>;
|
||||
System.out.println(k);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main4(String[] args) {
|
||||
final int i = 1;
|
||||
int j = <warning descr="'0xffffffff & i' can be replaced with 'i'">0xffffffff & i</warning>;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = <warning descr="'0xffffffff | j' can be replaced with '0xffffffff'">0xffffffff | j</warning>;
|
||||
System.out.println(k);
|
||||
j = 6;
|
||||
k = <warning descr="'0xffffffff ^ j' can be replaced with '~j'">0xffffffff ^ j</warning>;
|
||||
System.out.println(k);
|
||||
}
|
||||
|
||||
void longExpressions(int i, int j) {
|
||||
i = <warning descr="'j & 0 & 100' can be replaced with '0'">j & 0 & 100</warning>;
|
||||
}
|
||||
|
||||
void m(int i) {
|
||||
int h = <warning descr="'0 << 8' can be replaced with '0'">0 << 8</warning>;
|
||||
int b = <warning descr="'i ^ i' can be replaced with '0'">i ^ i</warning>; // 0
|
||||
int c = <warning descr="'i & i' can be replaced with 'i'">i & i</warning>; // i
|
||||
int d = <warning descr="'i | i' can be replaced with 'i'">i | i</warning>; // i
|
||||
}
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
package com.siyeh.igtest.bitwise.pointless_bitwise_expression;
|
||||
|
||||
public class PointlessBitwiseExpressionInspection {
|
||||
private static final int ZERO = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
final int i = 1;
|
||||
int j = i & 0;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = j | 0;
|
||||
System.out.println(k);
|
||||
k = j ^ 0;
|
||||
System.out.println(k);
|
||||
k = j << 0;
|
||||
System.out.println(k);
|
||||
k = j >> 0;
|
||||
System.out.println(k);
|
||||
k = j >>> 0;
|
||||
System.out.println(k);
|
||||
k = j >>> ZERO;
|
||||
System.out.println(k);
|
||||
}
|
||||
|
||||
public static void main3(String[] args) {
|
||||
final int i = 1;
|
||||
int j = 0 & i;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = 0 | j;
|
||||
System.out.println(k);
|
||||
k = 0 ^ j;
|
||||
System.out.println(k);
|
||||
|
||||
}
|
||||
|
||||
public static void main2(String[] args) {
|
||||
final int i = 1;
|
||||
int j = i & 0xffffffff;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = j | 0xffffffff;
|
||||
System.out.println(k);
|
||||
j = 6;
|
||||
k = j ^ 0xffffffff;
|
||||
System.out.println(k);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main4(String[] args) {
|
||||
final int i = 1;
|
||||
int j = 0xffffffff & i;
|
||||
System.out.println(j);
|
||||
j = 3;
|
||||
int k = 0xffffffff | j;
|
||||
System.out.println(k);
|
||||
j = 6;
|
||||
k = 0xffffffff ^ j;
|
||||
System.out.println(k);
|
||||
}
|
||||
|
||||
void longExpressions(int i, int j) {
|
||||
i = j & 0 & 100;
|
||||
}
|
||||
|
||||
void m(int i) {
|
||||
int h = 0 << 8;
|
||||
int b = i ^ i; // 0
|
||||
int c = i & i; // i
|
||||
int d = i | i; // i
|
||||
}
|
||||
}
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>8</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>i & 0</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>11</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j | 0</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>13</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j ^ 0</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>15</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j << 0</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>17</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j >> 0</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>19</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j >>> 0</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>21</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j >>> ZERO</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>27</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0 & i</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>30</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0 | j</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>32</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0 ^ j</code> can be replaced with 'j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>39</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>i & 0xffffffff</code> can be replaced with 'i' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>42</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j | 0xffffffff</code> can be replaced with '0xffffffff' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>45</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j ^ 0xffffffff</code> can be replaced with '~j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>53</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0xffffffff & i</code> can be replaced with 'i' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>56</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0xffffffff | j</code> can be replaced with '0xffffffff' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>59</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0xffffffff ^ j</code> can be replaced with '~j' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>64</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>j & 0 & 100</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>68</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>0 << 8</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>69</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>i ^ i</code> can be replaced with '0' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>70</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>i & i</code> can be replaced with 'i' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>PointlessBitwiseExpressionInspection.java</file>
|
||||
<line>71</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless bitwise expression</problem_class>
|
||||
<description><code>i | i</code> can be replaced with 'i' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+27
-5
@@ -1,11 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.bitwise;
|
||||
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PointlessBitwiseExpressionInspectionTest extends IGInspectionTestCase {
|
||||
public class PointlessBitwiseExpressionInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/bitwise/pointless_bitwise_expression",
|
||||
new PointlessBitwiseExpressionInspection());
|
||||
public void testPointlessBitwiseExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new PointlessBitwiseExpressionInspection();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user