Skip to content

Commit

Permalink
chore(rubocop): allow use of YAML.load for _mapdata.rb [skip ci]
Browse files Browse the repository at this point in the history
* Automated using myii/ssf-formula#296
  • Loading branch information
dafyddj committed Mar 8, 2021
1 parent 17a7fec commit 4f7e121
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,4 +51,5 @@ repos:
hooks:
- id: rstcheck
name: Check reST files using rstcheck
exclude: 'docs/CHANGELOG.rst'
args: [--report=warning]
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -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],
},
};
27 changes: 23 additions & 4 deletions test/integration/share/libraries/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SystemResource < Inspec.resource(1)
attr_reader :platform

def initialize
super
@platform = build_platform
end

Expand All @@ -26,33 +27,51 @@ 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
end

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'
# `2018` relase is named `1` in kitchen.yaml
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}"
Expand Down

0 comments on commit 4f7e121

Please sign in to comment.