puppet-lint-absolute_classname-check 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8457df6a20dcdc3263f3a9d07c24a46affe2ead023a08da5ae0ed52dc22763
|
4
|
+
data.tar.gz: 34e1a29a81bffae3cdcb73d47837576778d3ca36146d196822e7b59795b06254
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f84c2b01a0d6d5eaa56279b24459889f3e00be262dfb931c9e5ad0f9b9f24bc7b4eeb7c8975d7e66ddea506837828a82b0f8fc1968cf8afb8886f6ff70b9e0c
|
7
|
+
data.tar.gz: 2a804b84105435ff4be5e344e2b9cb95270c7d3ecda64e733cff498eb77f4379988119504b8a7f7a66599af2998c7ef91d1a07b491bfb7b9f6062bc5ac0fa62a
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@ puppet-lint-absolute_classname-check
|
|
5
5
|
[](https://rubygems.org/gems/puppet-lint-absolute_classname-check)
|
6
6
|
[](https://rubygems.org/gems/puppet-lint-absolute_classname-check)
|
7
7
|
[](https://coveralls.io/r/voxpupuli/puppet-lint-absolute_classname-check?branch=master)
|
8
|
-
[](https://gemnasium.com/voxpupuli/puppet-lint-absolute_classname-check)
|
9
8
|
[](#transfer-notice)
|
10
9
|
|
11
10
|
A puppet-lint plugin to check that classes are included by their absolute name.
|
@@ -39,26 +38,18 @@ gem 'puppet-lint-absolute_classname-check', :require => false
|
|
39
38
|
|
40
39
|
### Relative class name inclusion
|
41
40
|
|
42
|
-
Including a class by a relative name might lead to unexpected results [in Puppet 3](https://docs.puppet.com/puppet/3/lang_namespaces.html#relative-name-lookup-and-incorrect-name-resolution).
|
41
|
+
Including a class by a relative name might lead to unexpected results [in Puppet 3](https://docs.puppet.com/puppet/3/lang_namespaces.html#relative-name-lookup-and-incorrect-name-resolution). That's why a lot of manifests explicitly include by the absolute name. Since Puppet 4 names are always absolute and this is no longer needed. This lint check helps to clean up your manifests.
|
43
42
|
|
44
43
|
#### What you have done
|
45
44
|
|
46
45
|
```puppet
|
47
|
-
include foobar
|
46
|
+
include ::foobar
|
48
47
|
```
|
49
48
|
|
50
49
|
#### What you should have done
|
51
50
|
|
52
51
|
```puppet
|
53
|
-
include
|
54
|
-
```
|
55
|
-
|
56
|
-
#### Reverse this check
|
57
|
-
|
58
|
-
This check can be reversed to check for Puppet > 4.
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
PuppetLint.configuration.absolute_classname_reverse = true
|
52
|
+
include foobar
|
62
53
|
```
|
63
54
|
|
64
55
|
#### Disabling the check
|
@@ -87,7 +78,6 @@ Previously: https://github.com/camptocamp/puppet-lint-absolute_classname-check
|
|
87
78
|
|
88
79
|
To make a new release, please do:
|
89
80
|
* Update the version in the `puppet-lint-absolute_classname-check.gemspec` file
|
90
|
-
* Update the version in the Rakefile
|
91
81
|
* Install gems with `bundle install --with release --path .vendor`
|
92
82
|
* generate the changelog with `bundle exec rake changelog`
|
93
83
|
* Create a PR with it
|
@@ -1,14 +1,8 @@
|
|
1
1
|
PuppetLint.new_check(:relative_classname_inclusion) do
|
2
2
|
def check
|
3
|
+
message = 'class included by absolute name (::$class)'
|
4
|
+
|
3
5
|
tokens.each_with_index do |token, token_idx|
|
4
|
-
reverse = PuppetLint.configuration.absolute_classname_reverse || false
|
5
|
-
if reverse
|
6
|
-
pattern = '^(?!::)'
|
7
|
-
message = 'class included by absolute name (::$class)'
|
8
|
-
else
|
9
|
-
pattern = '^::'
|
10
|
-
message = 'class included by relative name'
|
11
|
-
end
|
12
6
|
if [:NAME,:FUNCTION_NAME].include?(token.type) && ['include','contain','require'].include?(token.value)
|
13
7
|
s = token.next_code_token
|
14
8
|
next if s.nil?
|
@@ -22,7 +16,7 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
22
16
|
in_function += 1
|
23
17
|
elsif in_function > 0 && n && n.type == :RPAREN
|
24
18
|
in_function -= 1
|
25
|
-
elsif in_function.zero? && s.value
|
19
|
+
elsif in_function.zero? && s.value.start_with?('::')
|
26
20
|
notify :warning, {
|
27
21
|
message: message,
|
28
22
|
line: s.line,
|
@@ -36,7 +30,7 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
36
30
|
elsif token.type == :CLASS and token.next_code_token.type == :LBRACE
|
37
31
|
s = token.next_code_token
|
38
32
|
while s.type != :COLON
|
39
|
-
if (s.type == :NAME || s.type == :SSTRING) && s.value
|
33
|
+
if (s.type == :NAME || s.type == :SSTRING) && s.value.start_with?('::')
|
40
34
|
notify :warning, {
|
41
35
|
message: message,
|
42
36
|
line: s.line,
|
@@ -51,11 +45,6 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
51
45
|
end
|
52
46
|
|
53
47
|
def fix(problem)
|
54
|
-
|
55
|
-
problem[:token].value = if reverse
|
56
|
-
problem[:token].value[2..-1]
|
57
|
-
else
|
58
|
-
'::' + problem[:token].value
|
59
|
-
end
|
48
|
+
problem[:token].value = problem[:token].value[2..-1]
|
60
49
|
end
|
61
50
|
end
|
@@ -1,419 +1,202 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'relative_classname_inclusion' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
context '
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
class { '::foobar': }
|
20
|
-
|
21
|
-
class foobar {
|
22
|
-
}
|
23
|
-
|
24
|
-
contain ::foobar
|
25
|
-
contain('::foobar')
|
26
|
-
contain(foobar(baz))
|
27
|
-
contain(foobar('baz'))
|
28
|
-
|
29
|
-
require ::foobar
|
30
|
-
require('::foobar')
|
31
|
-
require(foobar(baz))
|
32
|
-
require(foobar('baz'))
|
33
|
-
EOS
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should not detect any problems' do
|
37
|
-
expect(problems).to have(0).problems
|
38
|
-
end
|
39
|
-
end
|
4
|
+
let(:msg) { 'class included by absolute name (::$class)' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'when absolute names are used' do
|
8
|
+
let(:code) do
|
9
|
+
<<-EOS
|
10
|
+
include ::foobar
|
11
|
+
include('::foobar')
|
12
|
+
include(foobar(baz))
|
13
|
+
include(foobar('baz'))
|
14
|
+
|
15
|
+
include ::foo, ::bar
|
16
|
+
include('::foo', '::bar')
|
17
|
+
|
18
|
+
class { '::foobar': }
|
40
19
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
it 'should detect 7 problems' do
|
55
|
-
expect(problems).to have(7).problems
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should create warnings' do
|
59
|
-
expect(problems).to contain_warning(msg).on_line(1).in_column(19)
|
60
|
-
expect(problems).to contain_warning(msg).on_line(2).in_column(19)
|
61
|
-
expect(problems).to contain_warning(msg).on_line(3).in_column(19)
|
62
|
-
expect(problems).to contain_warning(msg).on_line(4).in_column(19)
|
63
|
-
expect(problems).to contain_warning(msg).on_line(5).in_column(19)
|
64
|
-
expect(problems).to contain_warning(msg).on_line(6).in_column(19)
|
65
|
-
expect(problems).to contain_warning(msg).on_line(7).in_column(19)
|
66
|
-
end
|
20
|
+
class foobar {
|
21
|
+
}
|
22
|
+
|
23
|
+
contain ::foobar
|
24
|
+
contain('::foobar')
|
25
|
+
contain(foobar(baz))
|
26
|
+
contain(foobar('baz'))
|
27
|
+
|
28
|
+
require ::foobar
|
29
|
+
require('::foobar')
|
30
|
+
require(foobar(baz))
|
31
|
+
require(foobar('baz'))
|
32
|
+
EOS
|
67
33
|
end
|
68
34
|
|
69
|
-
|
70
|
-
|
71
|
-
<<-EOS
|
72
|
-
file { '/path':
|
73
|
-
ensure => present,
|
74
|
-
require => Shellvar['http_proxy'],
|
75
|
-
}
|
76
|
-
EOS
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should detect no problems' do
|
80
|
-
expect(problems).to have(0).problems
|
81
|
-
end
|
35
|
+
it 'should detect 11 problems' do
|
36
|
+
expect(problems).to have(11).problems
|
82
37
|
end
|
83
38
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
it 'should detect no problems' do
|
97
|
-
expect(problems).to have(0).problems
|
98
|
-
end
|
39
|
+
it 'should create warnings' do
|
40
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
41
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
42
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(17)
|
43
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(24)
|
44
|
+
expect(problems).to contain_warning(msg).on_line(7).in_column(17)
|
45
|
+
expect(problems).to contain_warning(msg).on_line(7).in_column(26)
|
46
|
+
expect(problems).to contain_warning(msg).on_line(9).in_column(17)
|
47
|
+
expect(problems).to contain_warning(msg).on_line(14).in_column(17)
|
48
|
+
expect(problems).to contain_warning(msg).on_line(15).in_column(17)
|
49
|
+
expect(problems).to contain_warning(msg).on_line(19).in_column(17)
|
50
|
+
expect(problems).to contain_warning(msg).on_line(20).in_column(17)
|
99
51
|
end
|
100
52
|
end
|
101
53
|
|
102
|
-
context '
|
103
|
-
|
104
|
-
|
54
|
+
context 'when relative names are used' do
|
55
|
+
let(:code) do
|
56
|
+
<<-EOS
|
57
|
+
include foobar
|
58
|
+
include(foobar)
|
59
|
+
class { 'foobar': }
|
60
|
+
contain foobar
|
61
|
+
contain(foobar)
|
62
|
+
require foobar
|
63
|
+
require(foobar)
|
64
|
+
EOS
|
105
65
|
end
|
106
66
|
|
107
|
-
|
108
|
-
|
67
|
+
it 'should not detect a problem' do
|
68
|
+
expect(problems).to have(0).problems
|
109
69
|
end
|
70
|
+
end
|
110
71
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
include ::foo, ::bar
|
120
|
-
include('::foo', '::bar')
|
121
|
-
|
122
|
-
class { '::foobar': }
|
123
|
-
|
124
|
-
class foobar {
|
125
|
-
}
|
126
|
-
|
127
|
-
contain ::foobar
|
128
|
-
contain('::foobar')
|
129
|
-
contain(foobar(baz))
|
130
|
-
contain(foobar('baz'))
|
131
|
-
|
132
|
-
require ::foobar
|
133
|
-
require('::foobar')
|
134
|
-
require(foobar(baz))
|
135
|
-
require(foobar('baz'))
|
136
|
-
EOS
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should not detect any problems' do
|
140
|
-
expect(problems).to have(0).problems
|
141
|
-
end
|
72
|
+
context 'when the require metadata parameter is used' do
|
73
|
+
let(:code) do
|
74
|
+
<<-EOS
|
75
|
+
file { '/path':
|
76
|
+
ensure => present,
|
77
|
+
require => Shellvar['http_proxy'],
|
78
|
+
}
|
79
|
+
EOS
|
142
80
|
end
|
143
81
|
|
144
|
-
|
145
|
-
|
146
|
-
<<-EOS
|
147
|
-
include foobar
|
148
|
-
include(foobar)
|
149
|
-
class { 'foobar': }
|
150
|
-
contain foobar
|
151
|
-
contain(foobar)
|
152
|
-
require foobar
|
153
|
-
require(foobar)
|
154
|
-
EOS
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should detect 7 problems' do
|
158
|
-
expect(problems).to have(7).problems
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'should fix the problems' do
|
162
|
-
expect(problems).to contain_fixed(msg).on_line(1).in_column(19)
|
163
|
-
expect(problems).to contain_fixed(msg).on_line(2).in_column(19)
|
164
|
-
expect(problems).to contain_fixed(msg).on_line(3).in_column(19)
|
165
|
-
expect(problems).to contain_fixed(msg).on_line(4).in_column(19)
|
166
|
-
expect(problems).to contain_fixed(msg).on_line(5).in_column(19)
|
167
|
-
expect(problems).to contain_fixed(msg).on_line(6).in_column(19)
|
168
|
-
expect(problems).to contain_fixed(msg).on_line(7).in_column(19)
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should should add colons' do
|
172
|
-
expect(manifest).to eq(
|
173
|
-
<<-EOS
|
174
|
-
include ::foobar
|
175
|
-
include(::foobar)
|
176
|
-
class { '::foobar': }
|
177
|
-
contain ::foobar
|
178
|
-
contain(::foobar)
|
179
|
-
require ::foobar
|
180
|
-
require(::foobar)
|
181
|
-
EOS
|
182
|
-
)
|
183
|
-
end
|
82
|
+
it 'should detect no problems' do
|
83
|
+
expect(problems).to have(0).problems
|
184
84
|
end
|
185
85
|
end
|
186
86
|
|
187
|
-
|
188
|
-
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
189
|
-
|
87
|
+
context 'when require is a hash key' do
|
190
88
|
let(:code) do
|
191
89
|
<<-EOS
|
192
|
-
|
90
|
+
$defaults = {
|
91
|
+
require => Exec['apt_update'],
|
92
|
+
}
|
93
|
+
$defaults = {
|
94
|
+
'require' => Exec['apt_update'],
|
95
|
+
}
|
193
96
|
EOS
|
194
97
|
end
|
195
98
|
|
196
|
-
it 'should
|
99
|
+
it 'should detect no problems' do
|
197
100
|
expect(problems).to have(0).problems
|
198
101
|
end
|
199
102
|
end
|
200
103
|
end
|
201
104
|
|
202
|
-
|
105
|
+
context 'with fix enabled' do
|
203
106
|
before do
|
204
|
-
PuppetLint.configuration.
|
107
|
+
PuppetLint.configuration.fix = true
|
205
108
|
end
|
206
|
-
let(:msg) { 'class included by absolute name (::$class)' }
|
207
|
-
|
208
|
-
context 'with fix disabled' do
|
209
|
-
context 'when absolute names are used' do
|
210
|
-
let(:code) do
|
211
|
-
<<-EOS
|
212
|
-
include ::foobar
|
213
|
-
include('::foobar')
|
214
|
-
include(foobar(baz))
|
215
|
-
include(foobar('baz'))
|
216
|
-
|
217
|
-
include ::foo, ::bar
|
218
|
-
include('::foo', '::bar')
|
219
|
-
|
220
|
-
class { '::foobar': }
|
221
|
-
|
222
|
-
class foobar {
|
223
|
-
}
|
224
|
-
|
225
|
-
contain ::foobar
|
226
|
-
contain('::foobar')
|
227
|
-
contain(foobar(baz))
|
228
|
-
contain(foobar('baz'))
|
229
|
-
|
230
|
-
require ::foobar
|
231
|
-
require('::foobar')
|
232
|
-
require(foobar(baz))
|
233
|
-
require(foobar('baz'))
|
234
|
-
EOS
|
235
|
-
end
|
236
|
-
|
237
|
-
it 'should detect 11 problems' do
|
238
|
-
expect(problems).to have(11).problems
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'should create warnings' do
|
242
|
-
expect(problems).to contain_warning(msg).on_line(1).in_column(19)
|
243
|
-
expect(problems).to contain_warning(msg).on_line(2).in_column(19)
|
244
|
-
expect(problems).to contain_warning(msg).on_line(6).in_column(19)
|
245
|
-
expect(problems).to contain_warning(msg).on_line(6).in_column(26)
|
246
|
-
expect(problems).to contain_warning(msg).on_line(7).in_column(19)
|
247
|
-
expect(problems).to contain_warning(msg).on_line(7).in_column(28)
|
248
|
-
expect(problems).to contain_warning(msg).on_line(9).in_column(19)
|
249
|
-
expect(problems).to contain_warning(msg).on_line(14).in_column(19)
|
250
|
-
expect(problems).to contain_warning(msg).on_line(15).in_column(19)
|
251
|
-
expect(problems).to contain_warning(msg).on_line(19).in_column(19)
|
252
|
-
expect(problems).to contain_warning(msg).on_line(20).in_column(19)
|
253
|
-
end
|
254
|
-
end
|
255
109
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
include foobar
|
260
|
-
include(foobar)
|
261
|
-
class { 'foobar': }
|
262
|
-
contain foobar
|
263
|
-
contain(foobar)
|
264
|
-
require foobar
|
265
|
-
require(foobar)
|
266
|
-
EOS
|
267
|
-
end
|
268
|
-
|
269
|
-
it 'should not detect a problem' do
|
270
|
-
expect(problems).to have(0).problems
|
271
|
-
end
|
272
|
-
end
|
110
|
+
after do
|
111
|
+
PuppetLint.configuration.fix = false
|
112
|
+
end
|
273
113
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
EOS
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'should detect no problems' do
|
285
|
-
expect(problems).to have(0).problems
|
286
|
-
end
|
287
|
-
end
|
114
|
+
context 'when absolute names are used' do
|
115
|
+
let(:code) do
|
116
|
+
<<-EOS
|
117
|
+
include ::foobar
|
118
|
+
include('::foobar')
|
119
|
+
include(foobar(baz))
|
120
|
+
include(foobar('baz'))
|
288
121
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
require => Exec['apt_update'],
|
294
|
-
}
|
295
|
-
$defaults = {
|
296
|
-
'require' => Exec['apt_update'],
|
297
|
-
}
|
298
|
-
EOS
|
299
|
-
end
|
300
|
-
|
301
|
-
it 'should detect no problems' do
|
302
|
-
expect(problems).to have(0).problems
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
122
|
+
include ::foo, ::bar
|
123
|
+
include('::foo', '::bar')
|
124
|
+
|
125
|
+
class { '::foobar': }
|
306
126
|
|
307
|
-
|
308
|
-
|
309
|
-
|
127
|
+
class foobar {
|
128
|
+
}
|
129
|
+
|
130
|
+
contain ::foobar
|
131
|
+
contain('::foobar')
|
132
|
+
contain(foobar(baz))
|
133
|
+
contain(foobar('baz'))
|
134
|
+
|
135
|
+
require ::foobar
|
136
|
+
require('::foobar')
|
137
|
+
require(foobar(baz))
|
138
|
+
require(foobar('baz'))
|
139
|
+
EOS
|
310
140
|
end
|
311
141
|
|
312
|
-
|
313
|
-
|
142
|
+
it 'should detect 11 problems' do
|
143
|
+
expect(problems).to have(11).problems
|
314
144
|
end
|
315
145
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
class foobar {
|
330
|
-
}
|
331
|
-
|
332
|
-
contain ::foobar
|
333
|
-
contain('::foobar')
|
334
|
-
contain(foobar(baz))
|
335
|
-
contain(foobar('baz'))
|
336
|
-
|
337
|
-
require ::foobar
|
338
|
-
require('::foobar')
|
339
|
-
require(foobar(baz))
|
340
|
-
require(foobar('baz'))
|
341
|
-
EOS
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'should detect 11 problems' do
|
345
|
-
expect(problems).to have(11).problems
|
346
|
-
end
|
347
|
-
|
348
|
-
it 'should fix the problems' do
|
349
|
-
expect(problems).to contain_fixed(msg).on_line(1).in_column(19)
|
350
|
-
expect(problems).to contain_fixed(msg).on_line(2).in_column(19)
|
351
|
-
expect(problems).to contain_fixed(msg).on_line(6).in_column(19)
|
352
|
-
expect(problems).to contain_fixed(msg).on_line(6).in_column(26)
|
353
|
-
expect(problems).to contain_fixed(msg).on_line(7).in_column(19)
|
354
|
-
expect(problems).to contain_fixed(msg).on_line(7).in_column(28)
|
355
|
-
expect(problems).to contain_fixed(msg).on_line(9).in_column(19)
|
356
|
-
expect(problems).to contain_fixed(msg).on_line(14).in_column(19)
|
357
|
-
expect(problems).to contain_fixed(msg).on_line(15).in_column(19)
|
358
|
-
expect(problems).to contain_fixed(msg).on_line(19).in_column(19)
|
359
|
-
expect(problems).to contain_fixed(msg).on_line(20).in_column(19)
|
360
|
-
end
|
361
|
-
|
362
|
-
it 'should should remove colons' do
|
363
|
-
expect(manifest).to eq(
|
364
|
-
<<-EOS
|
365
|
-
include foobar
|
366
|
-
include('foobar')
|
367
|
-
include(foobar(baz))
|
368
|
-
include(foobar('baz'))
|
369
|
-
|
370
|
-
include foo, bar
|
371
|
-
include('foo', 'bar')
|
372
|
-
|
373
|
-
class { 'foobar': }
|
374
|
-
|
375
|
-
class foobar {
|
376
|
-
}
|
377
|
-
|
378
|
-
contain foobar
|
379
|
-
contain('foobar')
|
380
|
-
contain(foobar(baz))
|
381
|
-
contain(foobar('baz'))
|
382
|
-
|
383
|
-
require foobar
|
384
|
-
require('foobar')
|
385
|
-
require(foobar(baz))
|
386
|
-
require(foobar('baz'))
|
387
|
-
EOS
|
388
|
-
)
|
389
|
-
end
|
146
|
+
it 'should fix the problems' do
|
147
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(17)
|
148
|
+
expect(problems).to contain_fixed(msg).on_line(2).in_column(17)
|
149
|
+
expect(problems).to contain_fixed(msg).on_line(6).in_column(17)
|
150
|
+
expect(problems).to contain_fixed(msg).on_line(6).in_column(24)
|
151
|
+
expect(problems).to contain_fixed(msg).on_line(7).in_column(17)
|
152
|
+
expect(problems).to contain_fixed(msg).on_line(7).in_column(26)
|
153
|
+
expect(problems).to contain_fixed(msg).on_line(9).in_column(17)
|
154
|
+
expect(problems).to contain_fixed(msg).on_line(14).in_column(17)
|
155
|
+
expect(problems).to contain_fixed(msg).on_line(15).in_column(17)
|
156
|
+
expect(problems).to contain_fixed(msg).on_line(19).in_column(17)
|
157
|
+
expect(problems).to contain_fixed(msg).on_line(20).in_column(17)
|
390
158
|
end
|
391
159
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
160
|
+
it 'should should remove colons' do
|
161
|
+
expect(manifest).to eq(
|
162
|
+
<<-EOS
|
163
|
+
include foobar
|
164
|
+
include('foobar')
|
165
|
+
include(foobar(baz))
|
166
|
+
include(foobar('baz'))
|
167
|
+
|
168
|
+
include foo, bar
|
169
|
+
include('foo', 'bar')
|
170
|
+
|
171
|
+
class { 'foobar': }
|
172
|
+
|
173
|
+
class foobar {
|
174
|
+
}
|
175
|
+
|
176
|
+
contain foobar
|
177
|
+
contain('foobar')
|
178
|
+
contain(foobar(baz))
|
179
|
+
contain(foobar('baz'))
|
180
|
+
|
181
|
+
require foobar
|
182
|
+
require('foobar')
|
183
|
+
require(foobar(baz))
|
184
|
+
require(foobar('baz'))
|
185
|
+
EOS
|
186
|
+
)
|
408
187
|
end
|
409
188
|
end
|
410
189
|
|
411
|
-
|
412
|
-
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
413
|
-
|
190
|
+
context 'when relative names are used' do
|
414
191
|
let(:code) do
|
415
192
|
<<-EOS
|
416
|
-
|
193
|
+
include foobar
|
194
|
+
include(foobar)
|
195
|
+
class { 'foobar': }
|
196
|
+
contain foobar
|
197
|
+
contain(foobar)
|
198
|
+
require foobar
|
199
|
+
require(foobar)
|
417
200
|
EOS
|
418
201
|
end
|
419
202
|
|
@@ -422,4 +205,18 @@ describe 'relative_classname_inclusion' do
|
|
422
205
|
end
|
423
206
|
end
|
424
207
|
end
|
208
|
+
|
209
|
+
describe '(#12) behavior of lookup("foo", {merge => unique}).include' do
|
210
|
+
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
211
|
+
|
212
|
+
let(:code) do
|
213
|
+
<<-EOS
|
214
|
+
lookup(foo, {merge => unique}).include
|
215
|
+
EOS
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should not detect any problems' do
|
219
|
+
expect(problems).to have(0).problems
|
220
|
+
end
|
221
|
+
end
|
425
222
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-absolute_classname-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: mime-types
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: rake
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,14 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
124
|
requirements:
|
139
125
|
- - ">="
|
140
126
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
127
|
+
version: 2.1.0
|
142
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
130
|
- - ">="
|
145
131
|
- !ruby/object:Gem::Version
|
146
132
|
version: '0'
|
147
133
|
requirements: []
|
148
|
-
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.7.7
|
149
136
|
signing_key:
|
150
137
|
specification_version: 4
|
151
138
|
summary: A puppet-lint plugin to check that classes are included by their absolute
|