-
Notifications
You must be signed in to change notification settings - Fork 461
5958: RemoveTrailingWhitespace from plain text files #6013
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
Conversation
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
""", | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
""", | |
""" | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you're seeing from the changes here we already have a recipe specifically for text blocks; no need to cover those in your recipe implementation.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | ||
""", | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | |
""", | |
""" | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | ||
""", | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | |
""", | |
""" | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\s\s | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
\s\s | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | ||
\s\s | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
\s\s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\s\s | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
\s\s | |
\s\s | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
\s\s |
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | ||
\s\s | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
""", | ||
""" | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
""", | |
""" | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit,\s\s | |
\s\s | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. |
import org.openrewrite.Cursor; | ||
import org.openrewrite.Tree; | ||
|
||
public class RemoveTrailingWhitespaceVisitor<P> extends PlainTextVisitor<P> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's usually no need to have a separate named & public visitor class; typically you can inline these into the recipe itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the established pattern for other RemoveTrailingWhitespace implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we have some outdated patterns lingering; going forward let's start with a minimal public API.
@Test | ||
void removeTrailingFirst() { | ||
rewriteRun( | ||
text( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure, if this will work, but can you try adding a test which has a java()
program?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a RemoveTrailingWhitespace for Java (and a few others).
In the PR description
you can replace it with:
Which is more human friendly (issue status shown as icon) and triggers automatic GitHub closing of related issue. |
What's changed?
Recipe to remove trailing whitespace from plain-text files
What's your motivation?
Resolves #5958
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Patterned after other RemoveTrailingWhitespace recipes
Checklist