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

Add ability to only warn about some rules #989

Merged
merged 1 commit into from
Aug 25, 2020
Merged

Add ability to only warn about some rules #989

merged 1 commit into from
Aug 25, 2020

Conversation

ssbarnea
Copy link
Member

Adds a warn_list option were user can add rules that should not
affect the outcome of the linting, while they will still be identified.

This softer option makes linter easier to adopt while still reminding
users about issues they should seek to address.

@nre-ableton
Copy link
Contributor

This looks like a great way to solve some of the issues raised in the 4.3.0 update; thanks so much for this patch!

Copy link

@rafaelfolco rafaelfolco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, small typo

lib/ansiblelint/__main__.py Outdated Show resolved Hide resolved
@ssbarnea ssbarnea added this to the 4.3.2 milestone Aug 24, 2020
@@ -160,7 +162,7 @@ def get_cli_parser() -> argparse.ArgumentParser:
return parser


def merge_config(file_config, cli_config) -> NamedTuple:
def merge_config(file_config, cli_config) -> NamedTuple: # noqa: C901
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time to do the full review right now but adding complexity is unacceptable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not real complexity an you know it well, clearly not a reason to block this change. If you know how to avoid scalability issues with merge_config, you are welcomed to refactor it to avoid triggering C901 when newer option are added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of repetition here. It's not complex, but it is redundant. Maybe the complexity warning could be squashed with a refactor. Something along the lines of (untested)

for field in ('quiet', 'parseable', 'parseable_severity' ... ):
    if field in file_config:
        setattr(cli_config, field, getattr(cli_config, field) or file_config[field]))
# Repeat again for addition/extend

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg-hellings Yes, it may work but it should be a follow-up and C901 should not be used as a ransom for forcing someone to refactor merge_config. This change itself does not add that kind of complexity we want to avoid with C901.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssbarnea I agree. Spurious complexity should not be a reason to hold up positive changes. But refactoring should be tossed on the backlog of things to tackle. I've added an issue here for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the addition of this branch is not complex in itself, it does underscore this method should be refactored as it grows... I am ok with having that on the backlog as added ^.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awcrosby #999 was already submitted by @ssbarnea to address the complexity refactor.

@@ -154,8 +165,7 @@ def main() -> int:
print(formatter.format(match))

if matches:
hint_about_skips(matches)
return 2
return report_outcome(matches, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#992 will gate this so it only shows up when NOT quiet, paresable, or parsable_severity are True. Since again this is adding verbose output, I would expect it not to be enabled for those modes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the report_outcome method does the guarding around quiet/parseable itself.

lib/ansiblelint/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@greg-hellings greg-hellings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the typo, I think this looks good.

lib/ansiblelint/__main__.py Outdated Show resolved Hide resolved
@@ -154,8 +165,7 @@ def main() -> int:
print(formatter.format(match))

if matches:
hint_about_skips(matches)
return 2
return report_outcome(matches, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the report_outcome method does the guarding around quiet/parseable itself.

Adds a `warn_list` option were user can add rules that should not
affect the outcome of the linting, while they will still be identified.

This softer option makes linter easier to adopt while still reminding
users about issues they should seek to address.
@ssbarnea ssbarnea merged commit 1ed62bd into master Aug 25, 2020
@ssbarnea ssbarnea deleted the feature/warn branch January 1, 2021 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants