Skip to content

Commit

Permalink
SONARJAVA-4726 (external contribution) fix crash in SelfAssignementCheck
Browse files Browse the repository at this point in the history
Author: gtoison <[email protected]>
  • Loading branch information
erwan-serandour authored Dec 13, 2023
1 parent 252ade8 commit 4248c48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package checks;

class SelfAssignementCheck {
static int staticField = 0;

static {
staticField = staticField; // Noncompliant
}

int a, c = 0;
int[] b = {0};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static JavaQuickFix getQuickFix(AssignmentExpressionTree tree) {
MethodTree methodParent = (MethodTree) ExpressionUtils.getParentOfType(tree, Tree.Kind.METHOD, Tree.Kind.CONSTRUCTOR);
String name = getName(tree.variable());

boolean isMethodParameter = methodParent.parameters().stream()
boolean isMethodParameter = methodParent != null && methodParent.parameters().stream()
.map(p -> p.simpleName().name())
.anyMatch(p -> p.equals(name));

Expand Down

0 comments on commit 4248c48

Please sign in to comment.