mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-22 04:40:42 +00:00
feat: add rule CheckMetaChangeFromDefault
This commit is contained in:
parent
e878a3cc33
commit
e90b80f12f
32
ansiblelater/rules/CheckMetaChangeFromDefault.py
Normal file
32
ansiblelater/rules/CheckMetaChangeFromDefault.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (c) 2018, Ansible Project
|
||||||
|
from nested_lookup import nested_lookup
|
||||||
|
|
||||||
|
from ansiblelater.standard import StandardBase
|
||||||
|
|
||||||
|
|
||||||
|
class CheckMetaChangeFromDefault(StandardBase):
|
||||||
|
|
||||||
|
sid = "ANSIBLE0021"
|
||||||
|
description = "Roles meta/main.yml default values should be changed"
|
||||||
|
helptext = "meta/main.yml default values should be changed for: `{field}`"
|
||||||
|
version = "0.2"
|
||||||
|
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 = "{field}: {default}".format(field=field, default=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)
|
@ -34,4 +34,5 @@ Reviews are nothing without some rules or standards against which to review. ans
|
|||||||
| CheckCommandInsteadOfArgument | ANSIBLE0017 | Commands should not be used in place of module arguments. | |
|
| CheckCommandInsteadOfArgument | ANSIBLE0017 | Commands should not be used in place of module arguments. | |
|
||||||
| CheckFilePermissionMissing | ANSIBLE0018 | File permissions unset or incorrect. | |
|
| CheckFilePermissionMissing | ANSIBLE0018 | File permissions unset or incorrect. | |
|
||||||
| CheckFilePermissionOctal | ANSIBLE0019 | Octal file permissions must contain leading zero or be a string. | |
|
| CheckFilePermissionOctal | ANSIBLE0019 | Octal file permissions must contain leading zero or be a string. | |
|
||||||
| CheckGitHasVersion | ANSIBLE0020 | Git checkouts should use explicit version | |
|
| CheckGitHasVersion | ANSIBLE0020 | Git checkouts should use explicit version. | |
|
||||||
|
| CheckMetaChangeFromDefault | ANSIBLE0021 | Roles meta/main.yml default values should be changed. | |
|
||||||
|
Loading…
Reference in New Issue
Block a user