From 4f7e12129817f25bce8e58f8c9bbabbe97e46af8 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Mon, 8 Mar 2021 15:57:25 +0000 Subject: [PATCH] chore(rubocop): allow use of `YAML.load` for `_mapdata.rb` [skip ci] * Automated using https://github.com/myii/ssf-formula/pull/296 --- .pre-commit-config.yaml | 12 +++++----- .rubocop.yml | 3 +++ commitlint.config.js | 5 ++++ test/integration/share/libraries/system.rb | 27 ++++++++++++++++++---- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3dc79fa..ea8271b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,23 +17,22 @@ repos: stages: [manual] additional_dependencies: ['@commitlint/config-conventional@8.3.4'] always_run: true - - repo: https://github.com/adithyabsk/mirrors-rubocop - rev: v0.91.0 + - repo: https://github.com/rubocop-hq/rubocop + rev: v1.9.1 hooks: - id: rubocop name: Check Ruby files with rubocop args: [--debug] always_run: true pass_filenames: false - - repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 2.1.3 + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.7.1.1 hooks: - id: shellcheck name: Check shell scripts with shellcheck files: ^.*\.(sh|bash|ksh)$ types: [] - args: [] - - repo: https://github.com/adrienverge/yamllint.git + - repo: https://github.com/adrienverge/yamllint rev: v1.23.0 hooks: - id: yamllint @@ -52,4 +51,5 @@ repos: hooks: - id: rstcheck name: Check reST files using rstcheck + exclude: 'docs/CHANGELOG.rst' args: [--report=warning] diff --git a/.rubocop.yml b/.rubocop.yml index 7fd75ac..9367e99 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,5 +12,8 @@ Metrics/BlockLength: - describe # Increase from default of `25` Max: 30 +Security/YAMLLoad: + Exclude: + - test/integration/**/_mapdata.rb # Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config` diff --git a/commitlint.config.js b/commitlint.config.js index 2f9d1aa..4eb37f4 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1,8 @@ module.exports = { extends: ['@commitlint/config-conventional'], + rules: { + 'body-max-line-length': [2, 'always', 120], + 'footer-max-line-length': [2, 'always', 120], + 'header-max-length': [2, 'always', 72], + }, }; diff --git a/test/integration/share/libraries/system.rb b/test/integration/share/libraries/system.rb index ebd32b3..ba08443 100644 --- a/test/integration/share/libraries/system.rb +++ b/test/integration/share/libraries/system.rb @@ -10,6 +10,7 @@ class SystemResource < Inspec.resource(1) attr_reader :platform def initialize + super @platform = build_platform end @@ -26,8 +27,8 @@ def build_platform def build_platform_family case inspec.platform[:name] - when 'arch' - 'arch' + when 'arch', 'gentoo' + inspec.platform[:name] else inspec.platform[:family] end @@ -35,13 +36,16 @@ def build_platform_family def build_platform_name case inspec.platform[:name] - when 'amazon' - 'amazonlinux' + when 'amazon', 'oracle' + "#{inspec.platform[:name]}linux" + when 'windows_8.1_pro', 'windows_server_2019_datacenter' + 'windows' else inspec.platform[:name] end end + # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity def build_platform_release case inspec.platform[:name] when 'amazon' @@ -49,10 +53,25 @@ def build_platform_release inspec.platform[:release].gsub(/2018.*/, '1') when 'arch' 'base-latest' + when 'gentoo' + "#{inspec.platform[:release].split('.')[0]}-#{derive_gentoo_init_system}" + when 'opensuse' + # rubocop:disable Style/NumericLiterals,Layout/LineLength + inspec.platform[:release].to_i > 20210101 ? 'tumbleweed' : inspec.platform[:release] + # rubocop:enable Style/NumericLiterals,Layout/LineLength + when 'windows_8.1_pro' + '8.1' + when 'windows_server_2019_datacenter' + '2019-server' else inspec.platform[:release] end end + # rubocop:enable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity + + def derive_gentoo_init_system + inspec.command('systemctl').exist? ? 'sysd' : 'sysv' + end def build_platform_finger "#{build_platform_name}-#{build_finger_release}"