diff --git a/ansiblelater/data/standards.py b/ansiblelater/data/standards.py index 9035114..e99fb27 100644 --- a/ansiblelater/data/standards.py +++ b/ansiblelater/data/standards.py @@ -24,6 +24,7 @@ from ansiblelater.rules.yamlfiles import check_yaml_file from ansiblelater.rules.yamlfiles import check_yaml_has_content from ansiblelater.rules.yamlfiles import check_yaml_hyphens from ansiblelater.rules.yamlfiles import check_yaml_indent +from ansiblelater.rules.yamlfiles import check_yaml_document_end from ansiblelater.standard import Standard tasks_should_be_separated = Standard(dict( @@ -224,6 +225,14 @@ use_yaml_rather_than_key_value = Standard(dict( types=["playbook", "task", "handler"] )) +files_should_contain_document_end_marker = Standard(dict( + id="LINT0009", + name="YAML should contain document end marker", + check=check_yaml_document_end, + version="0.1", + types=["playbook", "task", "handler", "rolevars", + "hostvars", "groupvars", "meta"] +)) ansible_min_version = "2.5" ansible_later_min_version = "0.2.0" @@ -256,4 +265,5 @@ standards = [ rolesfile_should_be_in_yaml, files_should_not_be_purposeless, use_yaml_rather_than_key_value, + files_should_contain_document_end_marker, ] diff --git a/ansiblelater/rules/yamlfiles.py b/ansiblelater/rules/yamlfiles.py index 3e4ab4b..29f30c3 100644 --- a/ansiblelater/rules/yamlfiles.py +++ b/ansiblelater/rules/yamlfiles.py @@ -75,6 +75,13 @@ def check_yaml_document_start(candidate, settings): return Result(candidate.path, errors) +def check_yaml_document_end(candidate, settings): + options = "rules: {{document-end: {conf}}}".format( + conf=settings["yamllint"]["document-end"]) + errors = run_yamllint(candidate.path, options) + return Result(candidate.path, errors) + + def check_yaml_colons(candidate, settings): options = "rules: {{colons: {conf}}}".format( conf=settings["yamllint"]["colons"]) diff --git a/ansiblelater/settings.py b/ansiblelater/settings.py index 0311ced..495c9a8 100644 --- a/ansiblelater/settings.py +++ b/ansiblelater/settings.py @@ -127,6 +127,9 @@ class Settings(object): "document-start": { "present": True }, + "document-end": { + "present": True + }, "colons": { "max-spaces-before": 0, "max-spaces-after": 1