mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-28 07:40:36 +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`.
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# Copyright (c) 2018, Ansible Project
|
|
from nested_lookup import nested_lookup
|
|
|
|
from ansiblelater.rule import RuleBase
|
|
|
|
|
|
class CheckMetaChangeFromDefault(RuleBase):
|
|
sid = "ANSIBLE0021"
|
|
description = "Roles meta/main.yml default values should be changed"
|
|
helptext = "meta/main.yml default values should be changed for: `{field}`"
|
|
types = ["meta"]
|
|
|
|
def check(self, candidate, settings):
|
|
content, errors = self.get_raw_yaml(candidate, settings)
|
|
field_defaults = [
|
|
("author", "your name"),
|
|
("description", "your description"),
|
|
("company", "your company (optional)"),
|
|
("license", "license (GPLv2, CC-BY, etc)"),
|
|
("license", "license (GPL-2.0-or-later, MIT, etc)"),
|
|
]
|
|
|
|
if not errors:
|
|
for field, default in field_defaults:
|
|
pair = f"{field}: {default}"
|
|
lookup = nested_lookup(field, content)
|
|
if lookup and default in nested_lookup(field, content):
|
|
errors.append(self.Error(None, self.helptext.format(field=pair)))
|
|
|
|
return self.Result(candidate.path, errors)
|