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
--write: Optionally pass rule names to --write in cli #2051
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cognifloyd
commented
Mar 28, 2022
click v8.1.0 was just released which breaks black v22.1.0. black v22.3.0 fixes the incompatibility.
This comment was marked as outdated.
This comment was marked as outdated.
ssbarnea
reviewed
Mar 29, 2022
cognifloyd
force-pushed
the
filter-write
branch
2 times, most recently
from
March 29, 2022 17:21
5f5b968
to
8f38659
Compare
cognifloyd
force-pushed
the
filter-write
branch
from
March 29, 2022 17:22
8f38659
to
9f8e363
Compare
if the config file is not empty, then --write means use defaults from config file.
cognifloyd
commented
Mar 29, 2022
Comment on lines
+282
to
+293
help="Allow ansible-lint to reformat YAML files and run rule transforms " | ||
"(Reformatting YAML files standardizes spacing, quotes, etc. " | ||
"A rule transform can fix or simplify fixing issues identified by that rule). " | ||
"You can limit the effective rule transforms (the 'write_list') by passing a " | ||
"keywords 'all' or 'none' or a comma separated list of rule ids or rule tags. " | ||
"YAML reformatting happens whenever '--write' or '--write=' is used. " | ||
"'--write' and '--write=all' are equivalent: they allow all transforms to run. " | ||
"The effective list of transforms comes from 'write_list' in the config file, " | ||
"followed whatever '--write' args are provided on the commandline. " | ||
"'--write=none' resets the list of transforms to allow reformatting YAML " | ||
"without running any of the transforms (ie '--write=none,rule-id' will " | ||
"ignore write_list in the config file and only run the rule-id transform).", |
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 is too long for a help text. It presents as this wall of text:
--write [WRITE_LIST] Allow ansible-lint to reformat YAML files and run rule
transforms (Reformatting YAML files standardizes
spacing, quotes, etc. A rule transform can fix or
simplify fixing issues identified by that rule). You
can limit the effective rule transforms (the
'write_list') by passing a keywords 'all' or 'none' or
a comma separated list of rule ids or rule tags. YAML
reformatting happens whenever '--write' or '--write='
is used. '--write' and '--write=all' are equivalent:
they allow all transforms to run. The effective list
of transforms comes from 'write_list' in the config
file, followed whatever '--write' args are provided on
the commandline. '--write=none' resets the list of
transforms to allow reformatting YAML without running
any of the transforms (ie '--write=none,rule-id' will
ignore write_list in the config file and only run the
rule-id transform).
I guess the next thing to do is figure out where this might go in the docs and then post a link from the help text.
ssbarnea
approved these changes
Mar 30, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow users to control which transforms
ansible-lint --write
will run.Introduces
write_list
config file setting to complement the--write
command line option.Each of these accept special keywords
all
andnone
as well as a list of rule ids and rule tags.--write
defaults to whatever is in the config file. Ifwrite_list
is not populated in the config file, then--write
is effectively the same thing as--write=all
.--write=all
allows all transforms to run.--write=none
resets the list of transforms so that people can reformat YAML without running any of the transforms.You can also use the
none
keyword to reset the list so you can run only a different set of rules than what is in the config file (as in--write=none,rule-id
will run just rule-id even ifall
is in the config file).--write=rule-id
addsrule-id
towrite_list
from the config file. If the config file does not populatewrite_list
, then this means only run the transform for rulerule-id
.--write=rule-tag
works just like--write=rule-id
but references rule tags instead of rule ids.Here are some examples that ignore
write_list
in the config file and selects rules tagged withansible-2-11-upgrade
:This example just adds
ansible-2-11-upgrade
towrite_list
from the config file: