puppet-lint-absolute_classname-check 0.2.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8151b5f2ac93aa1535818002c3f0a9a506c2de42a4e48c34aa178de66e306f77
|
4
|
+
data.tar.gz: 35557e3d473126306e915a2938d1f76c7e63894e8f037ec441989380cf93afd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 258fdd9e006ba53677ffcf094656e8ee4d2a8e5578e0cac65add4be569a91f7c9bf27728199dd5705e4de350f58a363d2244c8ab69bb149ff25498192bfa1b5e
|
7
|
+
data.tar.gz: 9ece5d2055e39f6dd4cbe737d9aad9627b2bb22a3c2bd598d1cd32a2381e5f978a5522f4bd36de9c48d0b3feaa5cca3291f368ca47404a2f0d03d410482fee8d
|
data/README.md
CHANGED
@@ -10,6 +10,17 @@ puppet-lint-absolute_classname-check
|
|
10
10
|
|
11
11
|
A puppet-lint plugin to check that classes are included by their absolute name.
|
12
12
|
|
13
|
+
|
14
|
+
## Table of contents
|
15
|
+
|
16
|
+
* [Installing](#installing)
|
17
|
+
* [From the command line](#from-the-command-line)
|
18
|
+
* [In a Gemfile](#in-a-gemfile)
|
19
|
+
* [Checks](#checks)
|
20
|
+
* [Relative class name inclusion](#relative-class-name-inclusion)
|
21
|
+
* [Transfer notice](#transfer-notice)
|
22
|
+
* [Release Informaion](#release-information)
|
23
|
+
|
13
24
|
## Installing
|
14
25
|
|
15
26
|
### From the command line
|
@@ -28,7 +39,7 @@ gem 'puppet-lint-absolute_classname-check', :require => false
|
|
28
39
|
|
29
40
|
### Relative class name inclusion
|
30
41
|
|
31
|
-
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).
|
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).
|
32
43
|
|
33
44
|
#### What you have done
|
34
45
|
|
@@ -42,6 +53,14 @@ include foobar
|
|
42
53
|
include ::foobar
|
43
54
|
```
|
44
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
|
62
|
+
```
|
63
|
+
|
45
64
|
#### Disabling the check
|
46
65
|
|
47
66
|
To disable this check, you can add `--no-relative_classname_inclusion-check` to your puppet-lint command line.
|
@@ -63,3 +82,13 @@ The maintainer preferred that Puppet Community take ownership of the module for
|
|
63
82
|
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.
|
64
83
|
|
65
84
|
Previously: https://github.com/camptocamp/puppet-lint-absolute_classname-check
|
85
|
+
|
86
|
+
## Release information
|
87
|
+
|
88
|
+
To make a new release, please do:
|
89
|
+
* Update the version in the `puppet-lint-absolute_classname-check.gemspec` file
|
90
|
+
* Update the version in the Rakefile
|
91
|
+
* Install gems with `bundle install --with release --path .vendor`
|
92
|
+
* generate the changelog with `bundle exec rake changelog`
|
93
|
+
* Create a PR with it
|
94
|
+
* After it got merged, push a tag. Travis will do the actual release
|
@@ -1,10 +1,19 @@
|
|
1
1
|
PuppetLint.new_check(:relative_classname_inclusion) do
|
2
2
|
def check
|
3
3
|
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
|
4
12
|
if [:NAME,:FUNCTION_NAME].include?(token.type) && ['include','contain','require'].include?(token.value)
|
5
13
|
s = token.next_code_token
|
6
14
|
next if s.nil?
|
7
15
|
next if s.type == :FARROW
|
16
|
+
|
8
17
|
in_function = 0
|
9
18
|
while s.type != :NEWLINE
|
10
19
|
n = s.next_code_token
|
@@ -13,12 +22,12 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
13
22
|
in_function += 1
|
14
23
|
elsif in_function > 0 && n && n.type == :RPAREN
|
15
24
|
in_function -= 1
|
16
|
-
elsif in_function
|
25
|
+
elsif in_function.zero? && s.value !~ /#{pattern}/
|
17
26
|
notify :warning, {
|
18
|
-
:message
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
27
|
+
message: message,
|
28
|
+
line: s.line,
|
29
|
+
column: s.column,
|
30
|
+
token: s
|
22
31
|
}
|
23
32
|
end
|
24
33
|
end
|
@@ -27,21 +36,26 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
27
36
|
elsif token.type == :CLASS and token.next_code_token.type == :LBRACE
|
28
37
|
s = token.next_code_token
|
29
38
|
while s.type != :COLON
|
30
|
-
if (s.type == :NAME || s.type == :SSTRING) && s.value !~
|
39
|
+
if (s.type == :NAME || s.type == :SSTRING) && s.value !~ /#{pattern}/
|
31
40
|
notify :warning, {
|
32
|
-
:message
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
41
|
+
message: message,
|
42
|
+
line: s.line,
|
43
|
+
column: s.column,
|
44
|
+
token: s
|
36
45
|
}
|
37
46
|
end
|
38
47
|
s = s.next_token
|
39
48
|
end
|
40
49
|
end
|
41
50
|
end
|
42
|
-
end
|
51
|
+
end
|
43
52
|
|
44
53
|
def fix(problem)
|
45
|
-
|
54
|
+
reverse = PuppetLint.configuration.absolute_classname_reverse || false
|
55
|
+
problem[:token].value = if reverse
|
56
|
+
problem[:token].value[2..-1]
|
57
|
+
else
|
58
|
+
'::' + problem[:token].value
|
59
|
+
end
|
46
60
|
end
|
47
61
|
end
|
@@ -1,199 +1,425 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'relative_classname_inclusion' do
|
4
|
-
|
4
|
+
describe '(default)' do
|
5
|
+
let(:msg) { 'class included by relative name' }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
context 'with fix disabled' do
|
8
|
+
context 'when absolute names are used' do
|
9
|
+
let(:code) do
|
10
|
+
<<-EOS
|
11
|
+
include ::foobar
|
12
|
+
include('::foobar')
|
13
|
+
include(foobar(baz))
|
14
|
+
include(foobar('baz'))
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
include ::foo, ::bar
|
17
|
+
include('::foo', '::bar')
|
17
18
|
|
18
|
-
|
19
|
+
class { '::foobar': }
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
class foobar {
|
22
|
+
}
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
contain ::foobar
|
25
|
+
contain('::foobar')
|
26
|
+
contain(foobar(baz))
|
27
|
+
contain(foobar('baz'))
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
require ::foobar
|
30
|
+
require('::foobar')
|
31
|
+
require(foobar(baz))
|
32
|
+
require(foobar('baz'))
|
33
|
+
EOS
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
it 'should not detect any problems' do
|
37
|
+
expect(problems).to have(0).problems
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
context 'when relative names are used' do
|
42
|
+
let(:code) do
|
43
|
+
<<-EOS
|
44
|
+
include foobar
|
45
|
+
include(foobar)
|
46
|
+
class { 'foobar': }
|
47
|
+
contain foobar
|
48
|
+
contain(foobar)
|
49
|
+
require foobar
|
50
|
+
require(foobar)
|
51
|
+
EOS
|
52
|
+
end
|
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
|
51
67
|
end
|
52
68
|
|
53
|
-
|
54
|
-
|
69
|
+
context 'when the require metadata parameter is used' do
|
70
|
+
let(:code) do
|
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
|
55
82
|
end
|
56
83
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
84
|
+
context 'when require is a hash key' do
|
85
|
+
let(:code) do
|
86
|
+
<<-EOS
|
87
|
+
$defaults = {
|
88
|
+
require => Exec['apt_update'],
|
89
|
+
}
|
90
|
+
$defaults = {
|
91
|
+
'require' => Exec['apt_update'],
|
92
|
+
}
|
93
|
+
EOS
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should detect no problems' do
|
97
|
+
expect(problems).to have(0).problems
|
98
|
+
end
|
65
99
|
end
|
66
100
|
end
|
67
101
|
|
68
|
-
context '
|
69
|
-
|
70
|
-
|
71
|
-
file { '/path':
|
72
|
-
ensure => present,
|
73
|
-
require => Shellvar['http_proxy'],
|
74
|
-
}
|
75
|
-
EOS
|
102
|
+
context 'with fix enabled' do
|
103
|
+
before do
|
104
|
+
PuppetLint.configuration.fix = true
|
76
105
|
end
|
77
106
|
|
78
|
-
|
79
|
-
|
107
|
+
after do
|
108
|
+
PuppetLint.configuration.fix = false
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when absolute names are used' do
|
112
|
+
let(:code) do
|
113
|
+
<<-EOS
|
114
|
+
include ::foobar
|
115
|
+
include('::foobar')
|
116
|
+
include(foobar(baz))
|
117
|
+
include(foobar('baz'))
|
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
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when relative names are used' do
|
145
|
+
let(:code) do
|
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
|
80
184
|
end
|
81
185
|
end
|
82
186
|
|
83
|
-
|
187
|
+
describe '(#12) behavior of lookup("foo", {merge => unique}).include' do
|
188
|
+
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
189
|
+
|
84
190
|
let(:code) do
|
85
191
|
<<-EOS
|
86
|
-
|
87
|
-
require => Exec['apt_update'],
|
88
|
-
}
|
89
|
-
$defaults = {
|
90
|
-
'require' => Exec['apt_update'],
|
91
|
-
}
|
192
|
+
lookup(foo, {merge => unique}).include
|
92
193
|
EOS
|
93
194
|
end
|
94
195
|
|
95
|
-
it 'should detect
|
196
|
+
it 'should not detect any problems' do
|
96
197
|
expect(problems).to have(0).problems
|
97
198
|
end
|
98
199
|
end
|
99
200
|
end
|
100
201
|
|
101
|
-
|
202
|
+
describe '(reversed)' do
|
102
203
|
before do
|
103
|
-
PuppetLint.configuration.
|
204
|
+
PuppetLint.configuration.absolute_classname_reverse = true
|
104
205
|
end
|
206
|
+
let(:msg) { 'class included by absolute name (::$class)' }
|
105
207
|
|
106
|
-
|
107
|
-
|
108
|
-
|
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'))
|
109
216
|
|
110
|
-
|
111
|
-
|
112
|
-
<<-EOS
|
113
|
-
include ::foobar
|
114
|
-
include('::foobar')
|
115
|
-
include(foobar(baz))
|
116
|
-
include(foobar('baz'))
|
217
|
+
include ::foo, ::bar
|
218
|
+
include('::foo', '::bar')
|
117
219
|
|
118
|
-
|
119
|
-
include('::foo', '::bar')
|
220
|
+
class { '::foobar': }
|
120
221
|
|
121
|
-
|
222
|
+
class foobar {
|
223
|
+
}
|
122
224
|
|
123
|
-
|
124
|
-
|
225
|
+
contain ::foobar
|
226
|
+
contain('::foobar')
|
227
|
+
contain(foobar(baz))
|
228
|
+
contain(foobar('baz'))
|
125
229
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
230
|
+
require ::foobar
|
231
|
+
require('::foobar')
|
232
|
+
require(foobar(baz))
|
233
|
+
require(foobar('baz'))
|
234
|
+
EOS
|
235
|
+
end
|
130
236
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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
|
136
254
|
end
|
137
255
|
|
138
|
-
|
139
|
-
|
256
|
+
context 'when relative names are used' do
|
257
|
+
let(:code) do
|
258
|
+
<<-EOS
|
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
|
273
|
+
|
274
|
+
context 'when the require metadata parameter is used' do
|
275
|
+
let(:code) do
|
276
|
+
<<-EOS
|
277
|
+
file { '/path':
|
278
|
+
ensure => present,
|
279
|
+
require => Shellvar['http_proxy'],
|
280
|
+
}
|
281
|
+
EOS
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should detect no problems' do
|
285
|
+
expect(problems).to have(0).problems
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context 'when require is a hash key' do
|
290
|
+
let(:code) do
|
291
|
+
<<-EOS
|
292
|
+
$defaults = {
|
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
|
140
304
|
end
|
141
305
|
end
|
142
306
|
|
143
|
-
context '
|
144
|
-
|
145
|
-
|
146
|
-
include foobar
|
147
|
-
include(foobar)
|
148
|
-
class { 'foobar': }
|
149
|
-
contain foobar
|
150
|
-
contain(foobar)
|
151
|
-
require foobar
|
152
|
-
require(foobar)
|
153
|
-
EOS
|
307
|
+
context 'with fix enabled' do
|
308
|
+
before do
|
309
|
+
PuppetLint.configuration.fix = true
|
154
310
|
end
|
155
311
|
|
156
|
-
|
157
|
-
|
312
|
+
after do
|
313
|
+
PuppetLint.configuration.fix = false
|
158
314
|
end
|
159
315
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
316
|
+
context 'when absolute names are used' do
|
317
|
+
let(:code) do
|
318
|
+
<<-EOS
|
319
|
+
include ::foobar
|
320
|
+
include('::foobar')
|
321
|
+
include(foobar(baz))
|
322
|
+
include(foobar('baz'))
|
323
|
+
|
324
|
+
include ::foo, ::bar
|
325
|
+
include('::foo', '::bar')
|
326
|
+
|
327
|
+
class { '::foobar': }
|
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
|
168
390
|
end
|
169
391
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
392
|
+
context 'when relative names are used' do
|
393
|
+
let(:code) do
|
394
|
+
<<-EOS
|
395
|
+
include foobar
|
396
|
+
include(foobar)
|
397
|
+
class { 'foobar': }
|
398
|
+
contain foobar
|
399
|
+
contain(foobar)
|
400
|
+
require foobar
|
401
|
+
require(foobar)
|
402
|
+
EOS
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'should not detect any problems' do
|
406
|
+
expect(problems).to have(0).problems
|
407
|
+
end
|
182
408
|
end
|
183
409
|
end
|
184
|
-
end
|
185
410
|
|
186
|
-
|
187
|
-
|
411
|
+
describe '(#12) behavior of lookup("foo", {merge => unique}).include' do
|
412
|
+
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
188
413
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
414
|
+
let(:code) do
|
415
|
+
<<-EOS
|
416
|
+
lookup(foo, {merge => unique}).include
|
417
|
+
EOS
|
418
|
+
end
|
194
419
|
|
195
|
-
|
196
|
-
|
420
|
+
it 'should not detect any problems' do
|
421
|
+
expect(problems).to have(0).problems
|
422
|
+
end
|
197
423
|
end
|
198
424
|
end
|
199
425
|
end
|
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: 0.
|
4
|
+
version: 1.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:
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -114,8 +114,8 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
-
description:
|
118
|
-
|
117
|
+
description: " A puppet-lint plugin to check that classes are included by their
|
118
|
+
absolute name.\n"
|
119
119
|
email: voxpupuli@groups.io
|
120
120
|
executables: []
|
121
121
|
extensions: []
|
@@ -145,12 +145,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.7.3
|
148
|
+
rubygems_version: 3.0.2
|
150
149
|
signing_key:
|
151
150
|
specification_version: 4
|
152
151
|
summary: A puppet-lint plugin to check that classes are included by their absolute
|
153
152
|
name.
|
154
153
|
test_files:
|
155
|
-
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|
156
154
|
- spec/spec_helper.rb
|
155
|
+
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|