Skip to content

Commit

Permalink
[#1197] fix static via this rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed Mar 13, 2024
1 parent 2d2dfef commit 4cf643c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml
Expand Up @@ -182,8 +182,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
//PrimaryExpression[
(./PrimaryPrefix[@ThisModifier=true()]) and
(./PrimarySuffix[
@Image=//FieldDeclaration[@Static=true()]/VariableDeclarator/VariableDeclaratorId/@Name
or @Image=//MethodDeclaration[@Static=true()]/@MethodName
@Image=./ancestor::ClassOrInterfaceBody[1]/ClassOrInterfaceBodyDeclaration/FieldDeclaration[@Static=true()]/VariableDeclarator/VariableDeclaratorId/@Name
or @Image=./ancestor::ClassOrInterfaceBody[1]/ClassOrInterfaceBodyDeclaration/MethodDeclaration[@Static=true()]/@MethodName
])
]
]]></value>
Expand Down
Expand Up @@ -12,6 +12,21 @@ public int another() {
}

public int addToNum(final int another) {
return another + StaticAccessToStaticFields.number();
return another + StaticAccessToStaticFields.number() + this.another();
}

class InternalClass {
final int num;

InternalClass(final int par) {
this.num = par;
}
static int another() {
return 1;
}

public int add(final int a) {
return a + this.num;
}
}
}

0 comments on commit 4cf643c

Please sign in to comment.