mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-22 12:50:42 +00:00
some bugfixes
This commit is contained in:
parent
eeb8647d97
commit
a1a0099c7d
@ -40,6 +40,7 @@ def main():
|
||||
|
||||
workers = max(multiprocessing.cpu_count() - 2, 2)
|
||||
p = multiprocessing.Pool(workers)
|
||||
errors = []
|
||||
for filename in files:
|
||||
lines = None
|
||||
candidate = candidates.classify(filename, settings, standards)
|
||||
@ -54,13 +55,15 @@ def main():
|
||||
LOG.info("Reviewing %s lines %s" % (candidate, lines))
|
||||
else:
|
||||
LOG.info("Reviewing all of %s" % candidate)
|
||||
p.imap(candidate.review, (settings, lines,))
|
||||
errors = errors + p.map(candidate.review, [(settings, lines)])
|
||||
else:
|
||||
LOG.info("Couldn't classify file %s" % filename)
|
||||
|
||||
p.close()
|
||||
p.join()
|
||||
|
||||
return 0 if sum(errors) == 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -102,12 +102,14 @@ class Candidate(object):
|
||||
|
||||
return target_standards
|
||||
|
||||
def review(self, settings, lines=None):
|
||||
def review(self, args):
|
||||
(settings, lines) = args
|
||||
errors = 0
|
||||
|
||||
for standard in self.standards:
|
||||
if type(self).__name__.lower() not in standard.types:
|
||||
continue
|
||||
|
||||
result = standard.check(self, settings.config)
|
||||
|
||||
if not result:
|
||||
@ -146,6 +148,8 @@ class Candidate(object):
|
||||
error=err), extra=flag_extra(err_labels))
|
||||
errors = errors + 1
|
||||
|
||||
return errors
|
||||
|
||||
def _format_id(self, standard_id):
|
||||
if standard_id and standard_id.strip():
|
||||
standard_id = "[{id}] ".format(id=standard_id.strip())
|
||||
|
@ -6,6 +6,7 @@ from ansiblelater.command.candidates import Error
|
||||
from ansiblelater.command.candidates import Result
|
||||
from ansiblelater.utils.rulehelper import get_raw_yaml
|
||||
from ansiblelater.utils.rulehelper import get_tasks
|
||||
from ansible.parsing.yaml.objects import AnsibleMapping
|
||||
|
||||
|
||||
def check_meta_main(candidate, settings):
|
||||
@ -27,6 +28,7 @@ def check_scm_in_src(candidate, settings):
|
||||
|
||||
if not errors:
|
||||
for role in roles:
|
||||
if isinstance(role, AnsibleMapping):
|
||||
if "+" in role.get("src"):
|
||||
errors.append(Error(role["__line__"], description))
|
||||
|
||||
|
@ -76,7 +76,8 @@ def check_yaml_document_start(candidate, settings):
|
||||
|
||||
|
||||
def check_yaml_colons(candidate, settings):
|
||||
options = "rules: {{colons: {conf}}}"
|
||||
options = "rules: {{colons: {conf}}}".format(
|
||||
conf=settings["yamllint"]["colons"])
|
||||
errors = run_yamllint(candidate.path, options)
|
||||
return Result(candidate.path, errors)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user