From 534b0eb04ffc40d7e96bdd1bb8240b1fbd3c10ad Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Wed, 11 Sep 2019 00:05:58 +0100 Subject: [PATCH] refactor(yamllint): restructure `ignores` like `yaml-files` --- ssf/defaults.yaml | 7 ++++++- ssf/files/default/.yamllint | 19 +++++++++++-------- ssf/formulas.yaml | 27 +++++++++++++++------------ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/ssf/defaults.yaml b/ssf/defaults.yaml index 46fed992..9e54d264 100644 --- a/ssf/defaults.yaml +++ b/ssf/defaults.yaml @@ -116,7 +116,12 @@ ssf_node_anchors: use_tofs: false yamllint: extends: default - ignore: [] + ignore: + default: + - 'node_modules/' + additional_ssf: + - 'test/**/states/**/*.sls' + additional: [] yaml-files: default: - '*.yaml' diff --git a/ssf/files/default/.yamllint b/ssf/files/default/.yamllint index 961d9a4f..fd31879c 100644 --- a/ssf/files/default/.yamllint +++ b/ssf/files/default/.yamllint @@ -1,13 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=yaml --- -{%- macro format_ignore(ignore_parent, first_ignores=[], width=4) %} +{%- macro format_ignore(ignore_parent, width=4) %} {%- filter indent(width) %} {%- if ignore_parent.ignore is defined %} ignore: | - {%- for first_ignore in first_ignores %} - {{ first_ignore }} - {%- endfor %} {%- for file in ignore_parent.ignore %} {{ file }} {%- endfor %} @@ -19,15 +16,21 @@ extends: {{ yamllint.extends }} # Files to ignore completely # 1. All YAML files under directory `node_modules/`, introduced during the Travis run +# 2. Any SLS files under directory `test/`, which are actually state files {%- if semrel_formula == 'ssf' %} -# 2. All Jinja templates under `ssf/files/` (result in `yamllint` syntax errors) +# 3. All Jinja templates under `ssf/files/` (result in `yamllint` syntax errors) # Not disabling via. `*.yml` since we may end up with non-Jinja YAML files here {%- elif semrel_formula == 'mysql' %} -# 2. Any YAML files using Jinja (result in `yamllint` syntax errors) +# 3. Any YAML files using Jinja (result in `yamllint` syntax errors) {%- elif semrel_formula == 'postgres' %} -# 2. All YAML files heavily reliant on Jinja; these can be tackled in a subsequent PR +# 3. All YAML files heavily reliant on Jinja; these can be tackled in a subsequent PR {%- endif %} -{{- format_ignore(yamllint, first_ignores=['node_modules/'], width=0) }} +{%- set yl_ignores = {'ignore': + yamllint.ignore.default + + yamllint.ignore.additional_ssf + + yamllint.ignore.additional +} %} +{{- format_ignore(yl_ignores, width=0) }} yaml-files: {%- set yl_yf = yamllint.get('yaml-files') %} diff --git a/ssf/formulas.yaml b/ssf/formulas.yaml index 358aec63..889acba0 100644 --- a/ssf/formulas.yaml +++ b/ssf/formulas.yaml @@ -678,7 +678,8 @@ ssf: - [debian , 8 , 2017.7, 2, default] yamllint: ignore: - - mysql/supported_sections.yaml + additional: + - mysql/supported_sections.yaml semrel_files: *semrel_files_default nginx: context: @@ -854,12 +855,13 @@ ssf: use_tofs: true yamllint: ignore: - - pillar.example - - postgres/codenamemap.yaml - - postgres/osfamilymap.yaml - - postgres/osmap.yaml - - postgres/repo.yaml - - test/salt/pillar/postgres.sls + additional: + - pillar.example + - postgres/codenamemap.yaml + - postgres/osfamilymap.yaml + - postgres/osmap.yaml + - postgres/repo.yaml + - test/salt/pillar/postgres.sls semrel_files: *semrel_files_default prometheus: context: @@ -935,11 +937,12 @@ ssf: use_tofs: true yamllint: ignore: - - ssf/files/default/.cirrus.yml - - ssf/files/default/.travis.yml - - ssf/files/default/.yamllint - - ssf/files/default/kitchen.yml - - ssf/files/default/inspec/inspec.yml + additional: + - ssf/files/default/.cirrus.yml + - ssf/files/default/.travis.yml + - ssf/files/default/.yamllint + - ssf/files/default/kitchen.yml + - ssf/files/default/inspec/inspec.yml rules: commas: ignore: