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

yamlfmt: added and implemented functional features #43

Merged
merged 4 commits into from Sep 10, 2022

Conversation

RageCage64
Copy link
Contributor

While adding functionality for small edge cases or formatting differences, I found that the Formatter code was becoming harder to reason about. It would grow linearly with the number of little formatting things I had to do. I have adjusted the pattern to instead be a collection of functional features that can be added at-will.

Created a new Feature type that has a Before and After action. Also added the FeatureList type, with code to apply the before or after actions in order on byte slice input.

I converted all existing candidates in the formatter code to use this functional feature pattern instead.

While adding functionality for small edge cases or formatting
differences, I found that the Formatter code was becoming harder to
reason about. It would grow linearly with the number of little
formatting things I had to do. I have adjusted the pattern to instead be
a collection of functional features that can be added at-will.

Created a new `Feature` type that has a Before and After action. Also
added the FeatureList type, with code to apply the before or after
actions in order on byte slice input.

I converted all existing candidates in the formatter code to use this
functional feature pattern instead.
@google-cla
Copy link

google-cla bot commented Sep 10, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@braydonk
Copy link
Collaborator

This is me under my personal account (I made the fixes on my personal computer while I don't have access to my work one).

This wraps feature apply errors with the name and type of action.
Instead of a receiver method that configures the features in place on
the formatter, make it so the features are returned from a function that
reads the config. Avoids deliberate mutability.
@braydonk braydonk merged commit 6da562a into google:main Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants