View Javadoc
1   /*
2   RequireThis
3   checkFields = (default)true
4   checkMethods = false
5   validateOnlyOverlapping = false
6   
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;
11  
12  public class InputRequireThisExpressions {
13      String id;
14      int length;
15      boolean b;
16  
17      public void method(int[] arr) {
18          Object plus = "" + id; // violation 'Reference to instance variable 'id' needs "this.".'
19          Object minus = 1 - length; // violation '.* variable 'length' needs "this.".'
20          Object multi = 1 * length; // violation '.* variable 'length' needs "this.".'
21          Object div = 1 / length; // violation '.* variable 'length' needs "this.".'
22          Object mod = 1 % length; // violation '.* variable 'length' needs "this.".'
23          Object lt = 1 < length; // violation '.* variable 'length' needs "this.".'
24          Object gt = 1 > length; // violation '.* variable 'length' needs "this.".'
25          Object le = 1 <= length; // violation '.* variable 'length' needs "this.".'
26          Object ge = 1 >= length; // violation '.* variable 'length' needs "this.".'
27          Object equal = false == b; // violation '.* variable 'b' needs "this.".'
28          Object notEqual = false != b; // violation '.* variable 'b' needs "this.".'
29          Object sl = 1 << length; // violation '.* variable 'length' needs "this.".'
30          Object sr = 1 >> length; // violation '.* variable 'length' needs "this.".'
31          Object bsr = 1 >>> length; // violation '.* variable 'length' needs "this.".'
32          Object and = 1 & length; // violation '.* variable 'length' needs "this.".'
33          Object xor = 1 ^ length; // violation '.* variable 'length' needs "this.".'
34          Object bor = 1 | length; // violation '.* variable 'length' needs "this.".'
35          Object lor = false || b; // violation '.* variable 'b' needs "this.".'
36          Object land = false && b; // violation '.* variable 'b' needs "this.".'
37      }
38  
39      public void methodThis(int[] arr) {
40          Object plus = "" + this.id;
41          Object minus = 1 - this.length;
42          Object multi = 1 * this.length;
43          Object div = 1 / this.length;
44          Object mod = 1 % this.length;
45          Object lt = 1 < this.length;
46          Object gt = 1 > this.length;
47          Object le = 1 <= this.length;
48          Object ge = 1 >= this.length;
49          Object equal = false == this.b;
50          Object notEqual = false != this.b;
51          Object sl = 1 << this.length;
52          Object sr = 1 >> this.length;
53          Object bsr = 1 >>> this.length;
54          Object and = 1 & this.length;
55          Object xor = 1 ^ this.length;
56          Object bor = 1 | this.length;
57          Object lor = false || this.b;
58          Object land = false && this.b;
59  
60          Object fields = arr.length + this.length;
61      }
62  }