add exclude_filter option

This commit is contained in:
Robert Kaussow 2019-04-17 12:33:23 +02:00
parent 095e4b6e2e
commit cc8fad4d3c
5 changed files with 17 additions and 10 deletions

View File

@ -1,2 +1,2 @@
- BUGFIXES
- Fix multiprocessing handler causing performance issues
- ENHANCEMENT
- Add exclude_filter options ([#21](https://github.com/xoxys/ansible-later/issues/21))

View File

@ -108,9 +108,12 @@ rules:
# - molecule/
# - files/**/*.py
# List of Ansible rule ID's
# Limit checks to given rule ID's
# If empty all rules will be used.
filter: []
# Exclude given rule ID's from checks
exclude_filter: []
# All dotfiles (including hidden folders) are excluded by default.
# You can disable this setting and handle dotfiles by yourself with `exclude_files`.

View File

@ -22,6 +22,8 @@ def main():
help="location of standards rules")
parser.add_argument("-s", "--standards", dest="rules.filter", action="append",
help="limit standards to specific ID's")
parser.add_argument("-x", "--exclude-standards", dest="rules.exclude_filter", action="append",
help="exclude standards by ID")
parser.add_argument("-v", dest="logging.level", action="append_const", const=-1,
help="increase log level")
parser.add_argument("-q", dest="logging.level", action="append_const",

View File

@ -91,14 +91,15 @@ class Candidate(object):
def _get_standards(self, settings, standards):
target_standards = []
limits = settings.config["rules"]["filter"]
includes = settings.config["rules"]["filter"]
excludes = settings.config["rules"]["exclude_filter"]
if limits:
for standard in standards:
if standard.id in limits:
target_standards.append(standard)
else:
target_standards = standards
if len(includes) == 0:
includes = [s.id for s in standards]
for standard in standards:
if standard.id in includes and standard.id not in excludes:
target_standards.append(standard)
return target_standards

View File

@ -95,6 +95,7 @@ class Settings(object):
"rules": {
"standards": rules_dir,
"filter": [],
"exclude_filter": [],
"ignore_dotfiles": True,
"exclude_files": []
},