Skip to content

Commit ae14d44

Browse files
authored
Merge pull request #62 from eole/bugfix/make-rubycop-happy
fix(rubocop): make the cop happy
2 parents a22c209 + c7c5e57 commit ae14d44

19 files changed

+196
-153
lines changed

.rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ Metrics/LineLength:
77
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
88
Max: 88
99

10+
# libvirt-formula overredies
11+
Lint/AmbiguousRegexpLiteral:
12+
# Exclude { should match /<REGEX>/ }
13+
Exclude:
14+
- 'test/integration/default/controls/config_spec.rb'
15+
1016
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`

.travis.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ stages:
2121
- name: release
2222
if: branch = master AND type != pull_request
2323
jobs:
24-
allow_failures:
25-
- env: Lint_rubocop
26-
fast_finish: true
2724
include:
2825
## Define the test stage that runs the linters (and testing matrix, if applicable)
2926

30-
# Run all of the linters in a single job (except `rubocop`)
27+
# Run all of the linters in a single job
3128
- language: node_js
3229
node_js: lts/*
3330
env: Lint
34-
name: 'Lint: salt-lint, yamllint & commitlint'
31+
name: 'Lint: salt-lint, yamllint, rubocop & commitlint'
3532
before_install: skip
3633
script:
3734
# Install and run `salt-lint`
@@ -42,21 +39,13 @@ jobs:
4239
# Need at least `v1.17.0` for the `yaml-files` setting
4340
- pip install --user yamllint>=1.17.0
4441
- yamllint -s .
42+
# Install and run `rubocop`
43+
- gem install rubocop
44+
- rubocop -d
4545
# Install and run `commitlint`
4646
- npm install @commitlint/config-conventional -D
4747
- npm install @commitlint/travis-cli -D
4848
- commitlint-travis
49-
# Run the `rubocop` linter in a separate job that is allowed to fail
50-
# Once these lint errors are fixed, this can be merged into a single job
51-
- language: node_js
52-
node_js: lts/*
53-
env: Lint_rubocop
54-
name: 'Lint: rubocop'
55-
before_install: skip
56-
script:
57-
# Install and run `rubocop`
58-
- gem install rubocop
59-
- rubocop -d
6049

6150
## Define the rest of the matrix based on Kitchen testing
6251
# Make sure the instances listed below match up with
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# config_spec.rb -- Libvirt configuration InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
76

87
control 'Libvirt configuration' do
98
title 'the configuration files must not exist'
@@ -15,5 +14,4 @@
1514
describe file('/etc/libvirt/libvirtd.conf') do
1615
it { should_not exist }
1716
end
18-
1917
end
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# pkgs_spec.rb -- Libvirt packages InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
packages = libvirt.packages
88

99
control 'Libvirt packages' do
1010
title 'must be uninstalled'
1111

12-
packages.each do |service, pkgs|
13-
pkgs.each do |pkg|
14-
describe package(pkg) do
15-
it { should_not be_installed }
16-
end
12+
packages.values.flatten.each do |pkg|
13+
describe package(pkg) do
14+
it { should_not be_installed }
1715
end
1816
end
19-
2017
end

test/integration/clean/controls/service_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# service_spec.rb -- Libvirt service InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
control 'Libvirt service' do
88
title 'must be stopped and disabled'
99

test/integration/clean/controls/socket_admin_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# sockets_admin_spec.rb -- Libvirt sockets InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
control 'Libvirt admin socket' do
88
title 'must not exist'
99

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# sockets_ro_spec.rb -- Libvirt read only socket InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
control 'Libvirt read only socket' do
88
title 'must not exist'
99

1010
describe libvirt_socket_ro do
1111
it { should_not exist }
1212
end
13-
1413
end
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# sockets_rw_spec.rb -- Libvirt read/write socket InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
control 'Libvirt read/write socket' do
88
title 'must not exist'
99

1010
describe libvirt_socket_rw do
1111
it { should_not exist }
1212
end
13-
1413
end
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# config_spec.rb -- Libvirt configuration InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
76

87
params = {
98
'listen_tls' => '0',
@@ -16,31 +15,30 @@
1615
'unix_sock_rw_perms' => '0770',
1716
'auth_unix_ro' => 'none',
1817
'auth_unix_rw' => 'none',
19-
'auth_tcp' => 'none',
18+
'auth_tcp' => 'none'
2019
}
2120

2221
control 'Libvirt configuration' do
2322
title 'verify applied configuration'
2423

2524
describe libvirt.daemon_config_file do
2625
it { should exist }
27-
its('content') { should match %r{This\sfile\sis\smanaged\sby\sSalt} }
26+
its('content') { should match /This\sfile\sis\smanaged\sby\sSalt/ }
2827
end
2928

3029
describe file('/etc/libvirt/libvirtd.conf') do
3130
it { should exist }
32-
its('content') { should match %r{This\sfile\sis\smanaged\sby\sSalt} }
31+
its('content') { should match /This\sfile\sis\smanaged\sby\sSalt/ }
3332
end
3433

3534
parse_options = {
3635
# Value can be surrounded by quotes, or not
37-
assignment_regex: /^\s*([^=]*?)\s*=\s*['"]?(.*?)['"]?\s*$/,
36+
assignment_regex: /^\s*([^=]*?)\s*=\s*['"]?(.*?)['"]?\s*$/
3837
}
3938

4039
describe parse_config_file('/etc/libvirt/libvirtd.conf', parse_options) do
4140
params.each do |param, value|
4241
its(param) { should eq value }
4342
end
4443
end
45-
4644
end
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
# coding: utf-8
2-
#
1+
# frozen_string_literal: true
2+
33
# pkgs_spec.rb -- Libvirt packages InSpec control
44
# Author: Daniel Dehennin <[email protected]>
5-
# Copyright © 2019 Pôle de Compétences Logiciels Libres <[email protected]>
6-
#
5+
# Copyright (C) 2019 Pole de Competences Logiciels Libres <[email protected]>
6+
77
packages = libvirt.packages
88

99
control 'Libvirt packages' do
1010
title 'verify installed packages'
1111

12-
packages.each do |service, pkgs|
13-
pkgs.each do |pkg|
14-
describe package(pkg) do
15-
it { should be_installed }
16-
end
12+
packages.values.flatten.each do |pkg|
13+
describe package(pkg) do
14+
it { should be_installed }
1715
end
1816
end
19-
2017
end

0 commit comments

Comments
 (0)