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