diff --git a/src/main/java/org/checkstyle/autofix/recipe/FinalLocalVariable.java b/src/main/java/org/checkstyle/autofix/recipe/FinalLocalVariable.java index ec8fc14..d114830 100644 --- a/src/main/java/org/checkstyle/autofix/recipe/FinalLocalVariable.java +++ b/src/main/java/org/checkstyle/autofix/recipe/FinalLocalVariable.java @@ -105,7 +105,7 @@ private boolean isAtViolationLocation(J.VariableDeclarations.NamedVariable liter return violations.stream().anyMatch(violation -> { return violation.getLine() == line && violation.getColumn() == column - && Path.of(violation.getFileName()).equals(sourcePath); + && Path.of(violation.getFileName()).endsWith(sourcePath); }); } } diff --git a/src/main/java/org/checkstyle/autofix/recipe/Header.java b/src/main/java/org/checkstyle/autofix/recipe/Header.java index 08173cb..106a288 100644 --- a/src/main/java/org/checkstyle/autofix/recipe/Header.java +++ b/src/main/java/org/checkstyle/autofix/recipe/Header.java @@ -129,7 +129,7 @@ private String extractCurrentHeader(JavaSourceFile sourceFile) { private boolean hasViolation(Path filePath) { return violations.removeIf(violation -> { - return filePath.equals(Path.of(violation.getFileName()).toAbsolutePath()); + return Path.of(violation.getFileName()).endsWith(filePath); }); } } diff --git a/src/main/java/org/checkstyle/autofix/recipe/RedundantImport.java b/src/main/java/org/checkstyle/autofix/recipe/RedundantImport.java index 091f9ac..f2370f4 100644 --- a/src/main/java/org/checkstyle/autofix/recipe/RedundantImport.java +++ b/src/main/java/org/checkstyle/autofix/recipe/RedundantImport.java @@ -118,7 +118,7 @@ private boolean isAtViolationLocation(J.Import literal) { final Path absolutePath = Path.of(violation.getFileName()).toAbsolutePath(); return violation.getLine() == line && violation.getColumn() == column - && absolutePath.equals(sourcePath); + && absolutePath.endsWith(sourcePath); }); } diff --git a/src/main/java/org/checkstyle/autofix/recipe/UpperEll.java b/src/main/java/org/checkstyle/autofix/recipe/UpperEll.java index 8dd1ead..bdef7e1 100644 --- a/src/main/java/org/checkstyle/autofix/recipe/UpperEll.java +++ b/src/main/java/org/checkstyle/autofix/recipe/UpperEll.java @@ -97,7 +97,7 @@ private boolean isAtViolationLocation(J.Literal literal) { final Path absolutePath = Path.of(violation.getFileName()).toAbsolutePath(); return violation.getLine() == line && violation.getColumn() == column - && absolutePath.equals(sourcePath); + && absolutePath.endsWith(sourcePath); }); } }