Skip to content

Commit

Permalink
Address comments: Fix mutation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsamehsalah committed Nov 25, 2023
1 parent e79584e commit a7f652e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,16 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
if (IS_CONSTANT.matches(variableTree, state)
&& isFieldAccessModifierApplicable(variableTree, state)) {
VarSymbol variableSymbol = ASTHelpers.getSymbol(variableTree);
String variableName = variableSymbol.getSimpleName().toString();

if (variableSymbol != null) {
String variableName = variableSymbol.getSimpleName().toString();
if (!isVariableUpperSnakeCase(variableName) && !isVariableNameExcluded(variableName)) {
String replacement = toUpperSnakeCase(variableName);

if (!isVariableUpperSnakeCase(variableName)
&& !isVariableNameExcluded(variableName)) {
String replacement = toUpperSnakeCase(variableName);

if (variableSymbols.stream()
.noneMatch(s -> s.getSimpleName().toString().equals(replacement))) {
fixBuilder.merge(SuggestedFixes.renameVariable(variableTree, replacement, state));
} else {
reportConstantRenameBlocker(variableTree, replacement, state);
}
if (variableSymbols.stream()
.noneMatch(s -> s.getSimpleName().toString().equals(replacement))) {
fixBuilder.merge(SuggestedFixes.renameVariable(variableTree, replacement, state));
} else {
reportConstantRenameBlocker(variableTree, replacement, state);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void excludeFlaggedConstants() {
}

@Test
void IncludePublicConstants() {
void includePublicConstants() {
BugCheckerRefactoringTestHelper.newInstance(CanonicalConstantFieldName.class, getClass())
.setArgs("-XepOpt:CanonicalConstantFieldName:IncludePublicConstantFields=true")
.addInputLines(
Expand Down

0 comments on commit a7f652e

Please sign in to comment.