Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prohibit access to static members via instance reference ('this' keyw…
…ord).
- Loading branch information
Showing
5 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
qulice-pmd/src/test/resources/com/qulice/pmd/AccessToStaticFieldsViaThis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package foo; | ||
|
||
public final class AccessToStaticFieldsViaThis { | ||
private static final int num = 1; | ||
|
||
public int number() { | ||
return this.num; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
qulice-pmd/src/test/resources/com/qulice/pmd/AccessToStaticMethodsViaThis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package foo; | ||
|
||
public final class AccessToStaticMethodsViaThis { | ||
private static int number() { | ||
return 1; | ||
} | ||
|
||
public int another() { | ||
return 1 + this.number(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ce/pmd/NonStaticAccessToStaticFields.java → ...ulice/pmd/DirectAccessToStaticFields.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters