Skip to content

Commit

Permalink
SONARJAVA-1604 Do not take static final field into account (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
benzonico authored Jan 3, 2017
1 parent 10302ab commit 2703cce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 0 additions & 5 deletions its/ruling/src/test/resources/sonar-server/squid-S3066.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private static boolean isNotStaticOrFinal(ModifiersTree modifiersTree) {
}

private static boolean isMutableFinalMember(VariableTree variableTree) {
return ModifiersUtils.hasModifier(variableTree.modifiers(), Modifier.FINAL) && isMutableMember(variableTree);
ModifiersTree modifiersTree = variableTree.modifiers();
return !ModifiersUtils.hasModifier(modifiersTree, Modifier.STATIC) && ModifiersUtils.hasModifier(modifiersTree, Modifier.FINAL) && isMutableMember(variableTree);
}

private static boolean isMutableMember(VariableTree variableTree) {
Expand Down
3 changes: 2 additions & 1 deletion java-checks/src/test/files/checks/EnumMutableFieldCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public enum Continent3 {
private int landMass;
public final String[] regions; // Noncompliant {{Lower the visibility of this field.}}
public final java.util.Date date; // Noncompliant {{Lower the visibility of this field.}}

public static final String[] regions2;

Continent3(int countryCount, int landMass) {
this.countryCount = countryCount;
this.landMass = landMass;
Expand Down

0 comments on commit 2703cce

Please sign in to comment.