-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support content filters that only post a comment when a regex is not found #33
base: master
Are you sure you want to change the base?
Support content filters that only post a comment when a regex is not found #33
Conversation
.github/nitpicks.yml
Outdated
contentFilter: | ||
- '!always()' |
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.
Do you think non-matching content filters should be their own input? It might be a valid use case for one to want to match a string that does start with a !
🤔
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.
yeah we can do it that way too! I personally felt like these were two sides of the same coin so it made sense to use contentFilter for both
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.
I'll run a test to see what '!(!always())' will do as a content filter
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.
That actually appears to work. I ran a test with this as the content filter:
contentFilter:
- '!(!always())'
with this as the yaml, it produced a comment:
if: 'always()'
with this as the yaml, it did not produce a comment:
if: '!always()'
For example, I might want nitpicker to enforce that a regex is present in all .rb files such as "# frozen_string_literal: true". With this change you can specify
And a comment will only be posted if a file does not contain that regex.
Along with this PR I added a new example.yml file and a rule to the nitpicks.yml to test the change (I don't have permissions here but I tested it in my forked repo: https://github.com/sophiederosa/nitpicker/pull/1), I will delete that before it is merged in.