Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't quibble over trailing newlines. #4613

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState
} catch (FormatterException exception) {
return NO_MATCH;
}
if (formattedSource.equals(sourceValue)) {
if (formattedSource.trim().equals(((String) sourceValue).trim())) {
return NO_MATCH;
}
// This is a bit crude: but tokenize between the comma and the 2nd argument in order to work out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ void method() {
.doTest();
}

@Test
public void onlyDiffersByFinalNewline_noFinding() {
assume().that(Runtime.version().feature()).isAtLeast(14);

compilationHelper
.addSourceLines(
"Test.java",
"""
import com.google.errorprone.BugCheckerRefactoringTestHelper;

class Test {
void method(BugCheckerRefactoringTestHelper h) {
h.addInputLines(
"Test.java",
\"""
package foo;

class Test {
void method() {
int a = 1;
}
}\""");
}
}
""")
.doTest();
}

@Test
public void misformatted_suggestsFix() {
assume().that(Runtime.version().feature()).isAtLeast(14);
Expand Down
Loading