From 123f8fbcb521b9b8e5415542e3aa8871a608d781 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 10 Oct 2021 17:00:44 +0200 Subject: [PATCH] fix: report deprecated ansible-later features as warning by default (#233) --- ansiblelater/candidate.py | 20 +++++++++++--------- ansiblelater/settings.py | 1 + docs/content/configuration/defaults.md | 6 ++++++ docs/content/included_rules/_index.md | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ansiblelater/candidate.py b/ansiblelater/candidate.py index 23376aa..ae607ee 100644 --- a/ansiblelater/candidate.py +++ b/ansiblelater/candidate.py @@ -165,16 +165,18 @@ class Candidate(object): extra=flag_extra(err_labels) ) else: - LOG.error( - "{sid}Standard '{description}' not met:\n{path}:{error}".format( - sid=self._format_id(standard.sid), - description=standard.description, - path=self.path, - error=err - ), - extra=flag_extra(err_labels) + msg = "{sid}Standard '{description}' not met:\n{path}:{error}".format( + sid=self._format_id(standard.sid), + description=standard.description, + path=self.path, + error=err ) - errors = errors + 1 + + if standard.sid not in self.config["rules"]["warning_filter"]: + LOG.error(msg, extra=flag_extra(err_labels)) + errors = errors + 1 + else: + LOG.warning(msg, extra=flag_extra(err_labels)) return errors diff --git a/ansiblelater/settings.py b/ansiblelater/settings.py index e3266c5..2575c7a 100644 --- a/ansiblelater/settings.py +++ b/ansiblelater/settings.py @@ -120,6 +120,7 @@ class Settings(object): "standards": [], "filter": [], "exclude_filter": [], + "warning_filter": ["ANSIBLE9999"], "ignore_dotfiles": True, "exclude_files": [], "version": "" diff --git a/docs/content/configuration/defaults.md b/docs/content/configuration/defaults.md index 962772d..dda3d97 100644 --- a/docs/content/configuration/defaults.md +++ b/docs/content/configuration/defaults.md @@ -56,6 +56,12 @@ rules: # Exclude given rule ID's from checks exclude_filter: [] + # List of rule ID's that should be displayed as a warning instead of an error. By default, + # only rules whose version is higher than the current default version are marked as warnings. + # This list allows to degrade errors to warnings for each rule. + warning_filter: + - "ANSIBLE9999" + # All dotfiles (including hidden folders) are excluded by default. # You can disable this setting and handle dotfiles by yourself with `exclude_files`. ignore_dotfiles: True diff --git a/docs/content/included_rules/_index.md b/docs/content/included_rules/_index.md index 85d55d5..16f7aa3 100644 --- a/docs/content/included_rules/_index.md +++ b/docs/content/included_rules/_index.md @@ -41,3 +41,4 @@ Reviews are nothing without some rules or standards against which to review. ans | CheckLocalAction | ANSIBLE0024 | Don't use local_action. | | | CheckRelativeRolePaths | ANSIBLE0025 | Don't use a relative path in a role. | | | CheckChangedInWhen | ANSIBLE0026 | Use handlers instead of `when: changed`. | | +| CheckDeprecated | ANSIBLE9999 | Deprecated features of `ansible-later` should not be used. | |