puppet-lint-absolute_classname-check 0.2.4 → 3.0.1
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 +5 -13
- data/README.md +63 -10
- data/lib/puppet-lint/plugins/check_absolute_classname.rb +28 -14
- data/lib/puppet-lint/plugins/check_classname_reference.rb +26 -0
- data/spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb +93 -41
- data/spec/puppet-lint/plugins/check_classname_reference/relative_classname_reference_spec.rb +137 -0
- data/spec/spec_helper.rb +2 -5
- metadata +45 -59
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YmM5MDcwNjFhOTNjNmQ3NTczYThkZmRkZTE4Y2IwZTE3Y2IwODczYw==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0242bd18a491a4b01bfddbc2c16a09bdd988dfb2629c0e09297504f2e679cbfb
|
4
|
+
data.tar.gz: 15079e58e64171b9147a451c6bd937c70aa493c0a0c4cb28cd653e4c8adddaf4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZjkxNWZhM2IzY2ZjNzQ3OGNkYjk0ZGUyODUwYjc0YjJhN2I3MDVlZmQ4ZDVh
|
11
|
-
MjkxNGFjMTM1MjhjNmUyODdmZmMxZGE5YzM2YTliZjllMjdkNDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzcwMWVmODk1NzE4Y2NlZTQ4ODY0YWFlNTBhZDExZDlkMjA5NWZkYmFkYWI0
|
14
|
-
MGQxOWU5NWEzZDA1YTU1Njc2MDk2ZDQ0NGVhZGE4MTZjYzczMTRlOWQzN2Fm
|
15
|
-
MmE5MDU5YmFjOTc1MWZhZmJhOTc2NmU0YThhNTAwZDI3OWJhM2Q=
|
6
|
+
metadata.gz: ee1bf3d638248a5d8af48107cc7eb4f00c6ac5dcfa388b909f1a49fd00a08966c43d1963abbc21252a876b3488445609409cb55af377faaa40ba2b2584378b78
|
7
|
+
data.tar.gz: 356f61d658b2b154fae41285f5bcd192b3eaa44fc268443c842052683d64837faf3a9835be8c06b492d094c0dd476a419b02f5ff97c5fd887e0a4d9ab8d5c0db
|
data/README.md
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
puppet-lint-absolute_classname-check
|
2
2
|
====================================
|
3
3
|
|
4
|
-
[](https://github.com/voxpupuli/puppet-lint-absolute_classname-check/blob/master/LICENSE)
|
5
|
+
[](https://github.com/voxpupuli/puppet-lint-absolute_classname-check/actions/workflows/test.yml)
|
6
|
+
[](https://github.com/voxpupuli/puppet-lint-absolute_classname-check/actions/workflows/release.yml)
|
7
|
+
[](https://rubygems.org/gems/puppet-lint-absolute_classname-check)
|
8
|
+
[](https://rubygems.org/gems/puppet-lint-absolute_classname-check)
|
9
9
|
[](#transfer-notice)
|
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
|
+
* [Relative class reference](#relative-classname-reference)
|
22
|
+
* [Transfer notice](#transfer-notice)
|
23
|
+
* [Release Informaion](#release-information)
|
24
|
+
|
13
25
|
## Installing
|
14
26
|
|
15
27
|
### From the command line
|
@@ -28,32 +40,60 @@ gem 'puppet-lint-absolute_classname-check', :require => false
|
|
28
40
|
|
29
41
|
### Relative class name inclusion
|
30
42
|
|
31
|
-
Including a class by a relative name might lead to unexpected results.
|
43
|
+
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.
|
32
44
|
|
33
45
|
#### What you have done
|
34
46
|
|
47
|
+
```puppet
|
48
|
+
include ::foobar
|
49
|
+
```
|
50
|
+
|
51
|
+
#### What you should have done
|
52
|
+
|
35
53
|
```puppet
|
36
54
|
include foobar
|
37
55
|
```
|
38
56
|
|
57
|
+
#### Disabling the check
|
58
|
+
|
59
|
+
To disable this check, you can add `--no-relative_classname_inclusion-check` to your puppet-lint command line.
|
60
|
+
|
61
|
+
```shell
|
62
|
+
$ puppet-lint --no-relative_classname_inclusion-check path/to/file.pp
|
63
|
+
```
|
64
|
+
|
65
|
+
Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
PuppetLint.configuration.send('disable_relative_classname_inclusion')
|
69
|
+
```
|
70
|
+
|
71
|
+
### Relative class reference
|
72
|
+
|
73
|
+
#### What you have done
|
74
|
+
|
75
|
+
```puppet
|
76
|
+
Class['::foo'] -> Class['::bar']
|
77
|
+
```
|
78
|
+
|
39
79
|
#### What you should have done
|
40
80
|
|
41
81
|
```puppet
|
42
|
-
|
82
|
+
Class['foo'] -> Class['bar']
|
43
83
|
```
|
44
84
|
|
45
85
|
#### Disabling the check
|
46
86
|
|
47
|
-
To disable this check, you can add `--no-
|
87
|
+
To disable this check, you can add `--no-relative_classname_reference-check` to your puppet-lint command line.
|
48
88
|
|
49
89
|
```shell
|
50
|
-
$ puppet-lint --no-
|
90
|
+
$ puppet-lint --no-relative_classname_reference-check path/to/file.pp
|
51
91
|
```
|
52
92
|
|
53
93
|
Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
|
54
94
|
|
55
95
|
```ruby
|
56
|
-
PuppetLint.configuration.send('
|
96
|
+
PuppetLint.configuration.send('disable_relative_classname_reference')
|
57
97
|
```
|
58
98
|
|
59
99
|
## Transfer Notice
|
@@ -63,3 +103,16 @@ The maintainer preferred that Puppet Community take ownership of the module for
|
|
63
103
|
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.
|
64
104
|
|
65
105
|
Previously: https://github.com/camptocamp/puppet-lint-absolute_classname-check
|
106
|
+
|
107
|
+
## License
|
108
|
+
|
109
|
+
This gem is licensed under the Apache-2 license.
|
110
|
+
|
111
|
+
## Release information
|
112
|
+
|
113
|
+
To make a new release, please do:
|
114
|
+
* Update the version in the `puppet-lint-absolute_classname-check.gemspec` file
|
115
|
+
* Install gems with `bundle install --with release --path .vendor`
|
116
|
+
* generate the changelog with `bundle exec rake changelog`
|
117
|
+
* Create a PR with it
|
118
|
+
* After it got merged, push a tag. Travis will do the actual release
|
@@ -1,23 +1,27 @@
|
|
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
|
-
if token.type
|
6
|
+
if [:NAME,:FUNCTION_NAME].include?(token.type) && ['include','contain','require'].include?(token.value)
|
5
7
|
s = token.next_code_token
|
8
|
+
next if s.nil?
|
6
9
|
next if s.type == :FARROW
|
10
|
+
|
7
11
|
in_function = 0
|
8
12
|
while s.type != :NEWLINE
|
9
13
|
n = s.next_code_token
|
10
|
-
if
|
14
|
+
if [:NAME, :FUNCTION_NAME, :SSTRING,].include?(s.type)
|
11
15
|
if n && n.type == :LPAREN
|
12
16
|
in_function += 1
|
13
17
|
elsif in_function > 0 && n && n.type == :RPAREN
|
14
18
|
in_function -= 1
|
15
|
-
elsif in_function
|
19
|
+
elsif in_function.zero? && s.value.start_with?('::')
|
16
20
|
notify :warning, {
|
17
|
-
:message
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
+
message: message,
|
22
|
+
line: s.line,
|
23
|
+
column: s.column,
|
24
|
+
token: s
|
21
25
|
}
|
22
26
|
end
|
23
27
|
end
|
@@ -26,21 +30,31 @@ PuppetLint.new_check(:relative_classname_inclusion) do
|
|
26
30
|
elsif token.type == :CLASS and token.next_code_token.type == :LBRACE
|
27
31
|
s = token.next_code_token
|
28
32
|
while s.type != :COLON
|
29
|
-
if (s.type == :NAME || s.type == :SSTRING) && s.value
|
33
|
+
if (s.type == :NAME || s.type == :SSTRING) && s.value.start_with?('::')
|
30
34
|
notify :warning, {
|
31
|
-
:message
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
+
message: message,
|
36
|
+
line: s.line,
|
37
|
+
column: s.column,
|
38
|
+
token: s
|
35
39
|
}
|
36
40
|
end
|
37
41
|
s = s.next_token
|
38
42
|
end
|
43
|
+
elsif token.type == :INHERITS
|
44
|
+
s = token.next_code_token
|
45
|
+
if s.type == :NAME && s.value.start_with?('::')
|
46
|
+
notify :warning, {
|
47
|
+
message: message,
|
48
|
+
line: s.line,
|
49
|
+
column: s.column,
|
50
|
+
token: s
|
51
|
+
}
|
52
|
+
end
|
39
53
|
end
|
40
54
|
end
|
41
|
-
end
|
55
|
+
end
|
42
56
|
|
43
57
|
def fix(problem)
|
44
|
-
problem[:token].value =
|
58
|
+
problem[:token].value = problem[:token].value[2..-1]
|
45
59
|
end
|
46
60
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
PuppetLint.new_check(:relative_classname_reference) do
|
2
|
+
def check
|
3
|
+
message = 'absolute class name reference'
|
4
|
+
|
5
|
+
tokens.each_with_index do |token, token_idx|
|
6
|
+
if token.type == :TYPE and token.value == 'Class' and token.next_code_token.type == :LBRACK
|
7
|
+
s = token.next_code_token
|
8
|
+
while s.type != :RBRACK
|
9
|
+
if (s.type == :NAME || s.type == :SSTRING) && s.value.start_with?('::')
|
10
|
+
notify :warning, {
|
11
|
+
message: message,
|
12
|
+
line: s.line,
|
13
|
+
column: s.column,
|
14
|
+
token: s
|
15
|
+
}
|
16
|
+
end
|
17
|
+
s = s.next_token
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def fix(problem)
|
24
|
+
problem[:token].value = problem[:token].value[2..-1]
|
25
|
+
end
|
26
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'relative_classname_inclusion' do
|
4
|
-
let(:msg) { 'class included by
|
4
|
+
let(:msg) { 'class included by absolute name (::$class)' }
|
5
5
|
|
6
6
|
context 'with fix disabled' do
|
7
7
|
context 'when absolute names are used' do
|
@@ -29,11 +29,29 @@ describe 'relative_classname_inclusion' do
|
|
29
29
|
require('::foobar')
|
30
30
|
require(foobar(baz))
|
31
31
|
require(foobar('baz'))
|
32
|
+
|
33
|
+
class foobar inherits ::baz {
|
34
|
+
}
|
32
35
|
EOS
|
33
36
|
end
|
34
37
|
|
35
|
-
it 'should
|
36
|
-
expect(problems).to have(
|
38
|
+
it 'should detect 12 problems' do
|
39
|
+
expect(problems).to have(12).problems
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should create warnings' do
|
43
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
44
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
45
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(17)
|
46
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(24)
|
47
|
+
expect(problems).to contain_warning(msg).on_line(7).in_column(17)
|
48
|
+
expect(problems).to contain_warning(msg).on_line(7).in_column(26)
|
49
|
+
expect(problems).to contain_warning(msg).on_line(9).in_column(17)
|
50
|
+
expect(problems).to contain_warning(msg).on_line(14).in_column(17)
|
51
|
+
expect(problems).to contain_warning(msg).on_line(15).in_column(17)
|
52
|
+
expect(problems).to contain_warning(msg).on_line(19).in_column(17)
|
53
|
+
expect(problems).to contain_warning(msg).on_line(20).in_column(17)
|
54
|
+
expect(problems).to contain_warning(msg).on_line(24).in_column(31)
|
37
55
|
end
|
38
56
|
end
|
39
57
|
|
@@ -47,21 +65,13 @@ describe 'relative_classname_inclusion' do
|
|
47
65
|
contain(foobar)
|
48
66
|
require foobar
|
49
67
|
require(foobar)
|
68
|
+
class foobar inherits baz {
|
69
|
+
}
|
50
70
|
EOS
|
51
71
|
end
|
52
72
|
|
53
|
-
it 'should detect
|
54
|
-
expect(problems).to have(
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should create warnings' do
|
58
|
-
expect(problems).to contain_warning(msg).on_line(1).in_column(17)
|
59
|
-
expect(problems).to contain_warning(msg).on_line(2).in_column(17)
|
60
|
-
expect(problems).to contain_warning(msg).on_line(3).in_column(17)
|
61
|
-
expect(problems).to contain_warning(msg).on_line(4).in_column(17)
|
62
|
-
expect(problems).to contain_warning(msg).on_line(5).in_column(17)
|
63
|
-
expect(problems).to contain_warning(msg).on_line(6).in_column(17)
|
64
|
-
expect(problems).to contain_warning(msg).on_line(7).in_column(17)
|
73
|
+
it 'should not detect a problem' do
|
74
|
+
expect(problems).to have(0).problems
|
65
75
|
end
|
66
76
|
end
|
67
77
|
|
@@ -132,11 +142,61 @@ describe 'relative_classname_inclusion' do
|
|
132
142
|
require('::foobar')
|
133
143
|
require(foobar(baz))
|
134
144
|
require(foobar('baz'))
|
145
|
+
|
146
|
+
class foobar inherits ::baz {
|
147
|
+
}
|
135
148
|
EOS
|
136
149
|
end
|
137
150
|
|
138
|
-
it 'should
|
139
|
-
expect(problems).to have(
|
151
|
+
it 'should detect 12 problems' do
|
152
|
+
expect(problems).to have(12).problems
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should fix the problems' do
|
156
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(17)
|
157
|
+
expect(problems).to contain_fixed(msg).on_line(2).in_column(17)
|
158
|
+
expect(problems).to contain_fixed(msg).on_line(6).in_column(17)
|
159
|
+
expect(problems).to contain_fixed(msg).on_line(6).in_column(24)
|
160
|
+
expect(problems).to contain_fixed(msg).on_line(7).in_column(17)
|
161
|
+
expect(problems).to contain_fixed(msg).on_line(7).in_column(26)
|
162
|
+
expect(problems).to contain_fixed(msg).on_line(9).in_column(17)
|
163
|
+
expect(problems).to contain_fixed(msg).on_line(14).in_column(17)
|
164
|
+
expect(problems).to contain_fixed(msg).on_line(15).in_column(17)
|
165
|
+
expect(problems).to contain_fixed(msg).on_line(19).in_column(17)
|
166
|
+
expect(problems).to contain_fixed(msg).on_line(20).in_column(17)
|
167
|
+
expect(problems).to contain_fixed(msg).on_line(24).in_column(31)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should should remove colons' do
|
171
|
+
expect(manifest).to eq(
|
172
|
+
<<-EOS
|
173
|
+
include foobar
|
174
|
+
include('foobar')
|
175
|
+
include(foobar(baz))
|
176
|
+
include(foobar('baz'))
|
177
|
+
|
178
|
+
include foo, bar
|
179
|
+
include('foo', 'bar')
|
180
|
+
|
181
|
+
class { 'foobar': }
|
182
|
+
|
183
|
+
class foobar {
|
184
|
+
}
|
185
|
+
|
186
|
+
contain foobar
|
187
|
+
contain('foobar')
|
188
|
+
contain(foobar(baz))
|
189
|
+
contain(foobar('baz'))
|
190
|
+
|
191
|
+
require foobar
|
192
|
+
require('foobar')
|
193
|
+
require(foobar(baz))
|
194
|
+
require(foobar('baz'))
|
195
|
+
|
196
|
+
class foobar inherits baz {
|
197
|
+
}
|
198
|
+
EOS
|
199
|
+
)
|
140
200
|
end
|
141
201
|
end
|
142
202
|
|
@@ -150,36 +210,28 @@ describe 'relative_classname_inclusion' do
|
|
150
210
|
contain(foobar)
|
151
211
|
require foobar
|
152
212
|
require(foobar)
|
213
|
+
class foobar inherits baz {
|
214
|
+
}
|
153
215
|
EOS
|
154
216
|
end
|
155
217
|
|
156
|
-
it 'should detect
|
157
|
-
expect(problems).to have(
|
218
|
+
it 'should not detect any problems' do
|
219
|
+
expect(problems).to have(0).problems
|
158
220
|
end
|
221
|
+
end
|
222
|
+
end
|
159
223
|
|
160
|
-
|
161
|
-
|
162
|
-
expect(problems).to contain_fixed(msg).on_line(2).in_column(17)
|
163
|
-
expect(problems).to contain_fixed(msg).on_line(3).in_column(17)
|
164
|
-
expect(problems).to contain_fixed(msg).on_line(4).in_column(17)
|
165
|
-
expect(problems).to contain_fixed(msg).on_line(5).in_column(17)
|
166
|
-
expect(problems).to contain_fixed(msg).on_line(6).in_column(17)
|
167
|
-
expect(problems).to contain_fixed(msg).on_line(7).in_column(17)
|
168
|
-
end
|
224
|
+
describe '(#12) behavior of lookup("foo", {merge => unique}).include' do
|
225
|
+
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
169
226
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
require ::foobar
|
179
|
-
require(::foobar)
|
180
|
-
EOS
|
181
|
-
)
|
182
|
-
end
|
227
|
+
let(:code) do
|
228
|
+
<<-EOS
|
229
|
+
lookup(foo, {merge => unique}).include
|
230
|
+
EOS
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'should not detect any problems' do
|
234
|
+
expect(problems).to have(0).problems
|
183
235
|
end
|
184
236
|
end
|
185
237
|
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'relative_classname_reference' do
|
4
|
+
let(:msg) { 'absolute class name reference' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'when absolute names are used' do
|
8
|
+
let(:code) do
|
9
|
+
<<-EOS
|
10
|
+
Class[::foo] -> Class['::bar']
|
11
|
+
|
12
|
+
file { '/path':
|
13
|
+
ensure => present,
|
14
|
+
require => Class['::foo', '::bar'],
|
15
|
+
}
|
16
|
+
|
17
|
+
file { '/path':
|
18
|
+
ensure => present,
|
19
|
+
require => [Class[::foo], Class['::bar']],
|
20
|
+
}
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should detect 6 problems' do
|
25
|
+
expect(problems).to have(6).problems
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should create warnings' do
|
29
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(15)
|
30
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(31)
|
31
|
+
expect(problems).to contain_warning(msg).on_line(5).in_column(28)
|
32
|
+
expect(problems).to contain_warning(msg).on_line(5).in_column(37)
|
33
|
+
expect(problems).to contain_warning(msg).on_line(10).in_column(29)
|
34
|
+
expect(problems).to contain_warning(msg).on_line(10).in_column(43)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when relative names are used' do
|
39
|
+
let(:code) do
|
40
|
+
<<-EOS
|
41
|
+
Class[foo] -> Class['bar']
|
42
|
+
file { '/path':
|
43
|
+
ensure => present,
|
44
|
+
require => Class['foo', 'bar'],
|
45
|
+
}
|
46
|
+
file { '/path':
|
47
|
+
ensure => present,
|
48
|
+
require => [Class['foo'], Class['bar']],
|
49
|
+
}
|
50
|
+
EOS
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should not detect a problem' do
|
54
|
+
expect(problems).to have(0).problems
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with fix enabled' do
|
60
|
+
before do
|
61
|
+
PuppetLint.configuration.fix = true
|
62
|
+
end
|
63
|
+
|
64
|
+
after do
|
65
|
+
PuppetLint.configuration.fix = false
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when absolute names are used' do
|
69
|
+
let(:code) do
|
70
|
+
<<-EOS
|
71
|
+
Class[::foo] -> Class['::bar']
|
72
|
+
|
73
|
+
file { '/path':
|
74
|
+
ensure => present,
|
75
|
+
require => Class['::foo', '::bar'],
|
76
|
+
}
|
77
|
+
|
78
|
+
file { '/path':
|
79
|
+
ensure => present,
|
80
|
+
require => [Class[::foo], Class['::bar']],
|
81
|
+
}
|
82
|
+
EOS
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should detect 6 problems' do
|
86
|
+
expect(problems).to have(6).problems
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should fix the problems' do
|
90
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(15)
|
91
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(31)
|
92
|
+
expect(problems).to contain_fixed(msg).on_line(5).in_column(28)
|
93
|
+
expect(problems).to contain_fixed(msg).on_line(5).in_column(37)
|
94
|
+
expect(problems).to contain_fixed(msg).on_line(10).in_column(29)
|
95
|
+
expect(problems).to contain_fixed(msg).on_line(10).in_column(43)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should should remove colons' do
|
99
|
+
expect(manifest).to eq(
|
100
|
+
<<-EOS
|
101
|
+
Class[foo] -> Class['bar']
|
102
|
+
|
103
|
+
file { '/path':
|
104
|
+
ensure => present,
|
105
|
+
require => Class['foo', 'bar'],
|
106
|
+
}
|
107
|
+
|
108
|
+
file { '/path':
|
109
|
+
ensure => present,
|
110
|
+
require => [Class[foo], Class['bar']],
|
111
|
+
}
|
112
|
+
EOS
|
113
|
+
)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'when relative names are used' do
|
118
|
+
let(:code) do
|
119
|
+
<<-EOS
|
120
|
+
Class[foo] -> Class['bar']
|
121
|
+
file { '/path':
|
122
|
+
ensure => present,
|
123
|
+
require => Class['foo', 'bar'],
|
124
|
+
}
|
125
|
+
file { '/path':
|
126
|
+
ensure => present,
|
127
|
+
require => [Class[foo], Class['bar']],
|
128
|
+
}
|
129
|
+
EOS
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should not detect any problems' do
|
133
|
+
expect(problems).to have(0).problems
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,124 +1,108 @@
|
|
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: 3.0.1
|
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: 2021-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ~>
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '3.0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec-its
|
34
|
+
name: coveralls
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
50
36
|
requirements:
|
51
|
-
- -
|
37
|
+
- - ">="
|
52
38
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
39
|
+
version: '0'
|
54
40
|
type: :development
|
55
41
|
prerelease: false
|
56
42
|
version_requirements: !ruby/object:Gem::Requirement
|
57
43
|
requirements:
|
58
|
-
- -
|
44
|
+
- - ">="
|
59
45
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
46
|
+
version: '0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
48
|
+
name: rake
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
64
50
|
requirements:
|
65
|
-
- -
|
51
|
+
- - ">="
|
66
52
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
53
|
+
version: '0'
|
68
54
|
type: :development
|
69
55
|
prerelease: false
|
70
56
|
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
|
-
- -
|
58
|
+
- - ">="
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
60
|
+
version: '0'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
62
|
+
name: rspec
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
|
-
- -
|
65
|
+
- - ">="
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
67
|
+
version: '0'
|
82
68
|
type: :development
|
83
69
|
prerelease: false
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
|
-
- -
|
72
|
+
- - ">="
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
74
|
+
version: '0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
76
|
+
name: rspec-collection_matchers
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
92
78
|
requirements:
|
93
|
-
- -
|
79
|
+
- - ">="
|
94
80
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0
|
81
|
+
version: '0'
|
96
82
|
type: :development
|
97
83
|
prerelease: false
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
100
|
-
- -
|
86
|
+
- - ">="
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0
|
88
|
+
version: '0'
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
90
|
+
name: rspec-its
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
|
-
- -
|
93
|
+
- - ">="
|
108
94
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
95
|
+
version: '0'
|
110
96
|
type: :development
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
|
-
- -
|
100
|
+
- - ">="
|
115
101
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
117
|
-
description:
|
118
|
-
absolute name
|
119
|
-
|
120
|
-
'
|
121
|
-
email: raphael.pinson@camptocamp.com
|
102
|
+
version: '0'
|
103
|
+
description: " A puppet-lint plugin to check that classes are not included or referenced
|
104
|
+
by their absolute name.\n"
|
105
|
+
email: voxpupuli@groups.io
|
122
106
|
executables: []
|
123
107
|
extensions: []
|
124
108
|
extra_rdoc_files: []
|
@@ -126,9 +110,11 @@ files:
|
|
126
110
|
- LICENSE
|
127
111
|
- README.md
|
128
112
|
- lib/puppet-lint/plugins/check_absolute_classname.rb
|
113
|
+
- lib/puppet-lint/plugins/check_classname_reference.rb
|
129
114
|
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|
115
|
+
- spec/puppet-lint/plugins/check_classname_reference/relative_classname_reference_spec.rb
|
130
116
|
- spec/spec_helper.rb
|
131
|
-
homepage: https://github.com/
|
117
|
+
homepage: https://github.com/voxpupuli/puppet-lint-absolute_classname-check
|
132
118
|
licenses:
|
133
119
|
- Apache-2.0
|
134
120
|
metadata: {}
|
@@ -138,21 +124,21 @@ require_paths:
|
|
138
124
|
- lib
|
139
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
126
|
requirements:
|
141
|
-
- -
|
127
|
+
- - ">="
|
142
128
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
129
|
+
version: 2.1.0
|
144
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
131
|
requirements:
|
146
|
-
- -
|
132
|
+
- - ">="
|
147
133
|
- !ruby/object:Gem::Version
|
148
134
|
version: '0'
|
149
135
|
requirements: []
|
150
|
-
|
151
|
-
rubygems_version: 2.4.5
|
136
|
+
rubygems_version: 3.2.15
|
152
137
|
signing_key:
|
153
138
|
specification_version: 4
|
154
|
-
summary: A puppet-lint plugin to check that classes are included
|
155
|
-
name.
|
139
|
+
summary: A puppet-lint plugin to check that classes are not included or referenced
|
140
|
+
by their absolute name.
|
156
141
|
test_files:
|
157
142
|
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|
143
|
+
- spec/puppet-lint/plugins/check_classname_reference/relative_classname_reference_spec.rb
|
158
144
|
- spec/spec_helper.rb
|