puppet-lint 2.3.6 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -313,7 +313,7 @@ describe 'variable_scope' do
313
313
  end
314
314
 
315
315
  it 'should create one warning' do
316
- expect(problems).to contain_warning(msg).on_line(2).in_column(13)
316
+ expect(problems).to contain_warning(msg).on_line(2).in_column(14)
317
317
  end
318
318
  end
319
319
  end
@@ -105,4 +105,43 @@ describe 'case_without_default' do
105
105
  expect(problems).to have(0).problems
106
106
  end
107
107
  end
108
+
109
+ context 'issue-829 nested selector with default in case without default' do
110
+ let(:code) do
111
+ <<-END
112
+ case $::operatingsystem {
113
+ 'centos': {
114
+ $variable = $::operatingsystemmajrelease ? {
115
+ '7' => 'value1'
116
+ default => 'value2',
117
+ }
118
+ }
119
+ }
120
+ END
121
+ end
122
+
123
+ it 'should create one warning' do
124
+ expect(problems).to contain_warning(msg).on_line(1).in_column(9)
125
+ end
126
+ end
127
+
128
+ context 'issue-829 nested selector with default in case with default' do
129
+ let(:code) do
130
+ <<-END
131
+ case $::operatingsystem {
132
+ 'centos': {
133
+ $variable = $::operatingsystemmajrelease ? {
134
+ '7' => 'value1'
135
+ default => 'value2',
136
+ }
137
+ }
138
+ default: {}
139
+ }
140
+ END
141
+ end
142
+
143
+ it 'should not detect any problems' do
144
+ expect(problems).to have(0).problems
145
+ end
146
+ end
108
147
  end
@@ -80,6 +80,22 @@ describe 'ensure_first_param' do
80
80
  expect(problems).to have(0).problems
81
81
  end
82
82
  end
83
+
84
+ context 'ensure in nested hash' do
85
+ let(:code) do
86
+ <<-END
87
+ foo::bar { 'bar':
88
+ opts => {
89
+ ensure => present,
90
+ },
91
+ },
92
+ END
93
+ end
94
+
95
+ it 'should not detect any problems' do
96
+ expect(problems).to have(0).problems
97
+ end
98
+ end
83
99
  end
84
100
 
85
101
  context 'with fix enabled' do
@@ -12,7 +12,7 @@ describe 'only_variable_string' do
12
12
  end
13
13
 
14
14
  it 'should create a warning' do
15
- expect(problems).to contain_warning(msg).on_line(1).in_column(3)
15
+ expect(problems).to contain_warning(msg).on_line(1).in_column(4)
16
16
  end
17
17
  end
18
18
 
@@ -24,7 +24,7 @@ describe 'only_variable_string' do
24
24
  end
25
25
 
26
26
  it 'should create a warning' do
27
- expect(problems).to contain_warning(msg).on_line(1).in_column(3)
27
+ expect(problems).to contain_warning(msg).on_line(1).in_column(4)
28
28
  end
29
29
  end
30
30
 
@@ -36,7 +36,7 @@ describe 'only_variable_string' do
36
36
  end
37
37
 
38
38
  it 'should create a warning' do
39
- expect(problems).to contain_warning(msg).on_line(1).in_column(3)
39
+ expect(problems).to contain_warning(msg).on_line(1).in_column(4)
40
40
  end
41
41
  end
42
42
 
@@ -73,7 +73,7 @@ describe 'only_variable_string' do
73
73
  end
74
74
 
75
75
  it 'should fix the manifest' do
76
- expect(problems).to contain_fixed(msg).on_line(1).in_column(3)
76
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
77
77
  end
78
78
 
79
79
  it 'should unquote the variable' do
@@ -89,7 +89,7 @@ describe 'only_variable_string' do
89
89
  end
90
90
 
91
91
  it 'should fix the manifest' do
92
- expect(problems).to contain_fixed(msg).on_line(1).in_column(3)
92
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
93
93
  end
94
94
 
95
95
  it 'should unquoted the variable' do
@@ -105,7 +105,7 @@ describe 'only_variable_string' do
105
105
  end
106
106
 
107
107
  it 'should fix the manifest' do
108
- expect(problems).to contain_fixed(msg).on_line(1).in_column(3)
108
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
109
109
  end
110
110
 
111
111
  it 'should unquote the variable' do
@@ -86,5 +86,37 @@ describe 'variables_not_enclosed' do
86
86
  expect(manifest).to eq('"${foo}-${bar}"')
87
87
  end
88
88
  end
89
+
90
+ context 'variable with a hash or array reference not enclosed' do
91
+ let(:code) { %("$foo['bar'][2]something") }
92
+
93
+ it 'should only detect a single problem' do
94
+ expect(problems).to have(1).problem
95
+ end
96
+
97
+ it 'should fix the manifest' do
98
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(2)
99
+ end
100
+
101
+ it 'should enclose the variable with the references' do
102
+ expect(manifest).to eq(%("${foo['bar'][2]}something"))
103
+ end
104
+ end
105
+
106
+ context 'unenclosed variable followed by a dash and then text' do
107
+ let(:code) { '"$hostname-keystore"' }
108
+
109
+ it 'should only detect a single problem' do
110
+ expect(problems).to have(1).problem
111
+ end
112
+
113
+ it 'should fix the manifest' do
114
+ expect(problems).to contain_fixed(msg).on_line(1).in_column(2)
115
+ end
116
+
117
+ it 'should enclose the variable but not the text' do
118
+ expect(manifest).to eq('"${hostname}-keystore"')
119
+ end
120
+ end
89
121
  end
90
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2019-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Checks your Puppet manifests against the Puppetlabs
@@ -38,6 +38,7 @@ files:
38
38
  - lib/puppet-lint/configuration.rb
39
39
  - lib/puppet-lint/data.rb
40
40
  - lib/puppet-lint/lexer.rb
41
+ - lib/puppet-lint/lexer/string_slurper.rb
41
42
  - lib/puppet-lint/lexer/token.rb
42
43
  - lib/puppet-lint/monkeypatches.rb
43
44
  - lib/puppet-lint/optparser.rb
@@ -92,6 +93,7 @@ files:
92
93
  - spec/fixtures/test/manifests/init.pp
93
94
  - spec/fixtures/test/manifests/malformed.pp
94
95
  - spec/fixtures/test/manifests/mismatched_control_comment.pp
96
+ - spec/fixtures/test/manifests/two_warnings.pp
95
97
  - spec/fixtures/test/manifests/unterminated_control_comment.pp
96
98
  - spec/fixtures/test/manifests/url_interpolation.pp
97
99
  - spec/fixtures/test/manifests/warning.pp
@@ -100,6 +102,7 @@ files:
100
102
  - spec/puppet-lint/configuration_spec.rb
101
103
  - spec/puppet-lint/data_spec.rb
102
104
  - spec/puppet-lint/ignore_overrides_spec.rb
105
+ - spec/puppet-lint/lexer/string_slurper_spec.rb
103
106
  - spec/puppet-lint/lexer/token_spec.rb
104
107
  - spec/puppet-lint/lexer_spec.rb
105
108
  - spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb
@@ -159,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
162
  - !ruby/object:Gem::Version
160
163
  version: '0'
161
164
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.6.13
165
+ rubygems_version: 3.0.6
164
166
  signing_key:
165
167
  specification_version: 4
166
168
  summary: Ensure your Puppet manifests conform with the Puppetlabs style guide
@@ -173,6 +175,7 @@ test_files:
173
175
  - spec/fixtures/test/manifests/init.pp
174
176
  - spec/fixtures/test/manifests/malformed.pp
175
177
  - spec/fixtures/test/manifests/mismatched_control_comment.pp
178
+ - spec/fixtures/test/manifests/two_warnings.pp
176
179
  - spec/fixtures/test/manifests/unterminated_control_comment.pp
177
180
  - spec/fixtures/test/manifests/url_interpolation.pp
178
181
  - spec/fixtures/test/manifests/warning.pp
@@ -181,6 +184,7 @@ test_files:
181
184
  - spec/puppet-lint/configuration_spec.rb
182
185
  - spec/puppet-lint/data_spec.rb
183
186
  - spec/puppet-lint/ignore_overrides_spec.rb
187
+ - spec/puppet-lint/lexer/string_slurper_spec.rb
184
188
  - spec/puppet-lint/lexer/token_spec.rb
185
189
  - spec/puppet-lint/lexer_spec.rb
186
190
  - spec/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb