diff --git a/.yamllint b/.yamllint index 04440a0f..845783cc 100644 --- a/.yamllint +++ b/.yamllint @@ -15,6 +15,7 @@ ignore: | test/**/states/**/*.sls .kitchen/ ssf/files/default/.cirrus.yml + ssf/files/default/.rubocop.yml ssf/files/default/.travis.yml ssf/files/default/.yamllint ssf/files/default/kitchen.yml diff --git a/pillar.example b/pillar.example index bcae88d7..4d42e733 100644 --- a/pillar.example +++ b/pillar.example @@ -127,6 +127,7 @@ ssf: - inspec/README.md - .gitignore - .cirrus.yml + - .rubocop.yml - .salt-lint - .travis.yml - .yamllint diff --git a/ssf/config/formulas.sls b/ssf/config/formulas.sls index f19ec14c..16ade30a 100644 --- a/ssf/config/formulas.sls +++ b/ssf/config/formulas.sls @@ -109,6 +109,7 @@ prepare-git-branch-for-{{ formula }}: platforms: {{ context.platforms | yaml }} platforms_matrix: {{ context.platforms_matrix | yaml }} platforms_matrix_commented_includes: {{ context.platforms_matrix_commented_includes | yaml }} + rubocop: {{ context.rubocop | yaml }} salt_lint: {{ context.salt_lint | yaml }} script_kitchen: {{ context.script_kitchen | yaml }} suite: {{ suite | yaml }} diff --git a/ssf/defaults.yaml b/ssf/defaults.yaml index ab389c1b..d68106ec 100644 --- a/ssf/defaults.yaml +++ b/ssf/defaults.yaml @@ -164,6 +164,13 @@ ssf_node_anchors: # To deal with excessive instances when mimicking `kitchen list -b` # If values are set, only use these as commented entries in the matrix platforms_matrix_commented_includes: [] + rubocop: + AllCops: {} + Cops: + Metrics/LineLength: + Bugbear: *line_length_bugbear + Default: *line_length_default + Max: *line_length_bugbear salt_lint: {} script_kitchen: bin: bin/kitchen diff --git a/ssf/files/default/.rubocop.yml b/ssf/files/default/.rubocop.yml new file mode 100644 index 00000000..e2e69981 --- /dev/null +++ b/ssf/files/default/.rubocop.yml @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# General overrides used across formulas in the org +{%- set MLL = 'Metrics/LineLength' %} +{{ MLL }}: + {%- set rbcp_MLL = rubocop.Cops.get(MLL) %} + {%- if rbcp_MLL.Max == rbcp_MLL.Bugbear %} + # Increase from default of `{{ rbcp_MLL.Default }}` + # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) + {%- endif %} + Max: {{ rbcp_MLL.Max }} + +{%- if rubocop.AllCops %} + +# General settings across all cops in this formula +AllCops: + {#- This is purposefully simplistic for the time being, + until (if ever) more advanced configuration is necessary #} + {%- if rubocop.AllCops.Exclude %} + # Files to ignore completely + Exclude: + {%- for path in rubocop.AllCops.Exclude %} + - {{ path }} + {%- endfor %} + {%- endif %} +{%- endif %} + +# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config` +{%- for cop, config in rubocop.Cops.items() if cop not in [MLL] %} +{{ cop }}: + {#- This is purposefully simplistic for the time being, + until (if ever) more advanced configuration is necessary #} + {%- for k, v in config.items() %} + {{ k }}: {{ v }} + {%- endfor %} +{%- endfor %} diff --git a/ssf/formulas.yaml b/ssf/formulas.yaml index b8a615dc..6d37ca2e 100644 --- a/ssf/formulas.yaml +++ b/ssf/formulas.yaml @@ -181,6 +181,9 @@ ssf_node_anchors: .cirrus.yml: &file__--cirrus--yml <<: *file_default template: jinja + .rubocop.yml: &file__--rubocop--yml + <<: *file_default + template: jinja .salt-lint: &file__--salt-lint <<: *file_default template: jinja @@ -1259,6 +1262,7 @@ ssf: ignore: additional: - ssf/files/default/.cirrus.yml + - ssf/files/default/.rubocop.yml - ssf/files/default/.salt-lint - ssf/files/default/.travis.yml - ssf/files/default/.yamllint @@ -1278,6 +1282,7 @@ ssf: docs/TOFS_pattern.rst: *file__docs__TOFS_pattern--rst formula/libtofs.jinja: *file__formula__libtofs--jinja .gitignore: *file__--gitignore + .rubocop.yml: *file__--rubocop--yml .salt-lint: *file__--salt-lint .travis.yml: *file__--travis--yml .yamllint: *file__--yamllint