add exclude_filter option
This commit is contained in:
parent
095e4b6e2e
commit
cc8fad4d3c
|
@ -1,2 +1,2 @@
|
||||||
- BUGFIXES
|
- ENHANCEMENT
|
||||||
- Fix multiprocessing handler causing performance issues
|
- Add exclude_filter options ([#21](https://github.com/xoxys/ansible-later/issues/21))
|
||||||
|
|
|
@ -108,9 +108,12 @@ rules:
|
||||||
# - molecule/
|
# - molecule/
|
||||||
# - files/**/*.py
|
# - files/**/*.py
|
||||||
|
|
||||||
# List of Ansible rule ID's
|
# Limit checks to given rule ID's
|
||||||
# If empty all rules will be used.
|
# If empty all rules will be used.
|
||||||
filter: []
|
filter: []
|
||||||
|
|
||||||
|
# Exclude given rule ID's from checks
|
||||||
|
exclude_filter: []
|
||||||
|
|
||||||
# All dotfiles (including hidden folders) are excluded by default.
|
# All dotfiles (including hidden folders) are excluded by default.
|
||||||
# You can disable this setting and handle dotfiles by yourself with `exclude_files`.
|
# You can disable this setting and handle dotfiles by yourself with `exclude_files`.
|
||||||
|
|
|
@ -22,6 +22,8 @@ def main():
|
||||||
help="location of standards rules")
|
help="location of standards rules")
|
||||||
parser.add_argument("-s", "--standards", dest="rules.filter", action="append",
|
parser.add_argument("-s", "--standards", dest="rules.filter", action="append",
|
||||||
help="limit standards to specific ID's")
|
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,
|
parser.add_argument("-v", dest="logging.level", action="append_const", const=-1,
|
||||||
help="increase log level")
|
help="increase log level")
|
||||||
parser.add_argument("-q", dest="logging.level", action="append_const",
|
parser.add_argument("-q", dest="logging.level", action="append_const",
|
||||||
|
|
|
@ -91,14 +91,15 @@ class Candidate(object):
|
||||||
|
|
||||||
def _get_standards(self, settings, standards):
|
def _get_standards(self, settings, standards):
|
||||||
target_standards = []
|
target_standards = []
|
||||||
limits = settings.config["rules"]["filter"]
|
includes = settings.config["rules"]["filter"]
|
||||||
|
excludes = settings.config["rules"]["exclude_filter"]
|
||||||
|
|
||||||
if limits:
|
if len(includes) == 0:
|
||||||
for standard in standards:
|
includes = [s.id for s in standards]
|
||||||
if standard.id in limits:
|
|
||||||
target_standards.append(standard)
|
for standard in standards:
|
||||||
else:
|
if standard.id in includes and standard.id not in excludes:
|
||||||
target_standards = standards
|
target_standards.append(standard)
|
||||||
|
|
||||||
return target_standards
|
return target_standards
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ class Settings(object):
|
||||||
"rules": {
|
"rules": {
|
||||||
"standards": rules_dir,
|
"standards": rules_dir,
|
||||||
"filter": [],
|
"filter": [],
|
||||||
|
"exclude_filter": [],
|
||||||
"ignore_dotfiles": True,
|
"ignore_dotfiles": True,
|
||||||
"exclude_files": []
|
"exclude_files": []
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue