Skip to content

Commit 58fd47f

Browse files
committed
add --top-scope-variables cli argument, fix #228
1 parent 002f275 commit 58fd47f

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ Metrics/ClassLength:
6060
Metrics/CyclomaticComplexity:
6161
Max: 33
6262

63-
# Offense count: 80
63+
# Offense count: 81
6464
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
6565
Metrics/MethodLength:
66-
Max: 108
66+
Max: 111
6767

6868
# Offense count: 26
6969
# Configuration parameters: AllowedMethods, AllowedPatterns.

lib/puppet-lint/optparser.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ def self.build(args = [])
128128
PuppetLint.configuration.ignore_paths = paths.split(',')
129129
end
130130

131+
opts.on('--top-scope-variables VARS', 'A comma separated list of allowed top scope variables') do |vars|
132+
PuppetLint.configuration.top_scope_variables = vars.split(',')
133+
end
134+
131135
PuppetLint.configuration.checks.each do |check|
132136
opts.on("--no-#{check}-check", "Skip the #{check} check.") do
133137
PuppetLint.configuration.send(:"disable_#{check}")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# dummy resource to test --top-scope-variables
2+
define test::top_scope_variables() {
3+
notice($::role)
4+
}

spec/unit/puppet-lint/bin_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ def initialize(args)
121121
its(:stdout) { is_expected.to eq('') }
122122
end
123123

124+
context 'when passed top scope variables option' do
125+
let(:args) do
126+
[
127+
'--top-scope-variables=role',
128+
'spec/fixtures/test/manifests/top_scope_variables.pp',
129+
]
130+
end
131+
132+
its(:exitstatus) { is_expected.to eq(0) }
133+
its(:stdout) { is_expected.to eq('') }
134+
end
135+
124136
context 'when limited to errors only' do
125137
let(:args) do
126138
[

0 commit comments

Comments
 (0)