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: created content analyzer #106

Merged
merged 2 commits into from Apr 2, 2023
Merged

Conversation

braydonk
Copy link
Collaborator

@braydonk braydonk commented Apr 1, 2023

In some use cases the provided patterns of exclusion aren't enough, for example when something generates a lot of yaml files in weird places, or when single files should be ignored out of large directories. This PR adds the following:

  • The concept of and ability to read metadata, with the first type of metadata being "ignore"
  • A new ContentAnalyzer interface and a BasicContentAnalyzer which will accept an array of regex pattern strings. This will first read the metadata from the content of each file to find the ignore metadata, then will match the content to the regex patterns provided to determine which patterns will be excluded.

Closes #101

In some use cases the provided patterns of exclusion aren't enough, for
example when something generates a lot of yaml files in weird places, or
when single files should be ignored out of large directories. This PR
adds the following:
* The concept of and ability to read metadata, with the first type of
  metadata being "ignore"
* A new ContentAnalyzer interface and a BasicContentAnalyzer which will accept
  an array of regex pattern strings. This will first read the metadata
  from the content of each file to find the ignore metadata, then will
  match the content to the regex patterns provided to determine which
  patterns will be excluded.
@braydonk
Copy link
Collaborator Author

braydonk commented Apr 1, 2023

After I sleep on this I'm going to give it another look over to make sure it feels good, and add documentation.

Change metadata errors into a wrapped error struct so that the line
number and path can be included in the resulting error. Make metadata
errors non-fatal to `yamlfmt` as a whole. Also add the docs in this
commit.
@braydonk
Copy link
Collaborator Author

braydonk commented Apr 2, 2023

I feel good about this, gonna merge when the checks pass.

@braydonk braydonk merged commit 3a03733 into google:main Apr 2, 2023
4 checks passed
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.

Skip generated option
1 participant