mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-14 09:10:39 +00:00
Robert Kaussow
2df48598ec
BREAKING CHANGE: The option to define a `Standards` version has been removed. Every new rule that is added on upcoming releases is activated by default and will also create errors if triggered. The behavior of rules can be controlled by the existing `rules.exclude_filter` or `rules.warning_filter` options. BREAKING CHANGE: The option `rules.buildin` has been renamed to `rules.builtin`. BREAKING CHANGE: The option `rules.standards` has been renamed to `rules.dir`. BREAKING CHANGE: The option `rules.filter` has been renamed to `rules.include_filter`.
23 lines
864 B
Python
23 lines
864 B
Python
from ansiblelater.rule import RuleBase
|
|
|
|
|
|
class CheckNamedTask(RuleBase):
|
|
sid = "ANSIBLE0006"
|
|
description = "Tasks and handlers must be named"
|
|
helptext = "module `{module}` used without or empty `name` attribute"
|
|
types = ["playbook", "task", "handler"]
|
|
|
|
def check(self, candidate, settings):
|
|
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
|
exclude_modules = settings["ansible"]["named-task"]["exclude"]
|
|
|
|
if not errors:
|
|
for task in tasks:
|
|
module = task["action"]["__ansible_module__"]
|
|
if ("name" not in task or not task["name"]) and module not in exclude_modules:
|
|
errors.append(
|
|
self.Error(task["__line__"], self.helptext.format(module=module))
|
|
)
|
|
|
|
return self.Result(candidate.path, errors)
|