Skip to content

Commit e6538c1

Browse files
Anmol202005rdiachenko
authored andcommitted
Issue #88: Improving comparison logic
1 parent d9937de commit e6538c1

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/main/java/org/checkstyle/autofix/recipe/FinalLocalVariable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private boolean isAtViolationLocation(J.VariableDeclarations.NamedVariable liter
105105
return violations.stream().anyMatch(violation -> {
106106
return violation.getLine() == line
107107
&& violation.getColumn() == column
108-
&& Path.of(violation.getFileName()).equals(sourcePath);
108+
&& Path.of(violation.getFileName()).endsWith(sourcePath);
109109
});
110110
}
111111
}

src/main/java/org/checkstyle/autofix/recipe/Header.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private String extractCurrentHeader(JavaSourceFile sourceFile) {
129129

130130
private boolean hasViolation(Path filePath) {
131131
return violations.removeIf(violation -> {
132-
return filePath.equals(Path.of(violation.getFileName()).toAbsolutePath());
132+
return Path.of(violation.getFileName()).endsWith(filePath);
133133
});
134134
}
135135
}

src/main/java/org/checkstyle/autofix/recipe/RedundantImport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private boolean isAtViolationLocation(J.Import literal) {
118118
final Path absolutePath = Path.of(violation.getFileName()).toAbsolutePath();
119119
return violation.getLine() == line
120120
&& violation.getColumn() == column
121-
&& absolutePath.equals(sourcePath);
121+
&& absolutePath.endsWith(sourcePath);
122122
});
123123
}
124124

src/main/java/org/checkstyle/autofix/recipe/UpperEll.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private boolean isAtViolationLocation(J.Literal literal) {
9797
final Path absolutePath = Path.of(violation.getFileName()).toAbsolutePath();
9898
return violation.getLine() == line
9999
&& violation.getColumn() == column
100-
&& absolutePath.equals(sourcePath);
100+
&& absolutePath.endsWith(sourcePath);
101101
});
102102
}
103103
}

0 commit comments

Comments
 (0)