puppet-lint-absolute_classname-check 0.2.2 → 3.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 +5 -13
- data/README.md +56 -8
- data/lib/puppet-lint/plugins/check_absolute_classname.rb +29 -15
- data/lib/puppet-lint/plugins/check_classname_reference.rb +26 -0
- data/spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb +110 -41
- data/spec/puppet-lint/plugins/check_classname_reference/relative_classname_reference_spec.rb +137 -0
- data/spec/spec_helper.rb +2 -5
- metadata +46 -60
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmU4ZjZiMjlkZjJiNTI2OGUwZDNlYjg5YTk1OTA4YjUyOWQ5YjEzOQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d80c6cabf675148fec4eba47d1fe97898c981c5e80694d910357203a19e6ca14
|
4
|
+
data.tar.gz: 64ece9ae2635f02514bd25e6f9d5ed2f80c4f2880d7c0de9bbb6885c0b562b7f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZmQ0YjZiZDlhZmRjOGUyMzFhMWFkMzM1ZmMwNDVhMTJhMGZkODEwZGI4NWQ2
|
11
|
-
MTVhMDc4ODQ5MGY2MDVlZDM3NGEwNTg1N2M3Y2U2NThhMWUzNmQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjNhMzBmMzgzMTVmODhiYWVjYmZlYzM4NDFmZjcwNDBkZWQwYTRiNTM2MjJi
|
14
|
-
YzhjYzk1OTIyMjg1MmJjMjNiOTE0ZGY2ZTI5NTNlNGFhMzkyNzQ4ZmMzNDdh
|
15
|
-
OTg3MWViMjg5YWU1NThiMzQyMTc4OTZmYjQ1YzJkNTc2NzkxMzQ=
|
6
|
+
metadata.gz: 5a2f19eacda49f7211cd74e60914c0e9f07d76108268cfa918bf80c1eb4a4376838c6c2ef66c84d3c0ba5b4768ff208f5c751078724ca01a3017388cf2c0bf45
|
7
|
+
data.tar.gz: d08fff8a098711dcdda56193c83413196c90c8b228b5e16d91e9c34befe3bc0054c75d979e5827b6e42c3c3a99c83a46f7f3fc849b939525d053f5731252dd78
|
data/README.md
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
puppet-lint-absolute_classname-check
|
2
2
|
====================================
|
3
3
|
|
4
|
-
[](https://travis-ci.org/voxpupuli/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
|
-
[](https://gemnasium.com/puppet-community/puppet-lint-absolute_classname-check)
|
7
|
+
[](https://coveralls.io/r/voxpupuli/puppet-lint-absolute_classname-check?branch=master)
|
9
8
|
[](#transfer-notice)
|
10
9
|
|
11
10
|
A puppet-lint plugin to check that classes are included by their absolute name.
|
12
11
|
|
12
|
+
|
13
|
+
## Table of contents
|
14
|
+
|
15
|
+
* [Installing](#installing)
|
16
|
+
* [From the command line](#from-the-command-line)
|
17
|
+
* [In a Gemfile](#in-a-gemfile)
|
18
|
+
* [Checks](#checks)
|
19
|
+
* [Relative class name inclusion](#relative-class-name-inclusion)
|
20
|
+
* [Relative class reference](#relative-classname-reference)
|
21
|
+
* [Transfer notice](#transfer-notice)
|
22
|
+
* [Release Informaion](#release-information)
|
23
|
+
|
13
24
|
## Installing
|
14
25
|
|
15
26
|
### From the command line
|
@@ -28,32 +39,60 @@ 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.
|
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). 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
43
|
|
33
44
|
#### What you have done
|
34
45
|
|
46
|
+
```puppet
|
47
|
+
include ::foobar
|
48
|
+
```
|
49
|
+
|
50
|
+
#### What you should have done
|
51
|
+
|
35
52
|
```puppet
|
36
53
|
include foobar
|
37
54
|
```
|
38
55
|
|
56
|
+
#### Disabling the check
|
57
|
+
|
58
|
+
To disable this check, you can add `--no-relative_classname_inclusion-check` to your puppet-lint command line.
|
59
|
+
|
60
|
+
```shell
|
61
|
+
$ puppet-lint --no-relative_classname_inclusion-check path/to/file.pp
|
62
|
+
```
|
63
|
+
|
64
|
+
Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
PuppetLint.configuration.send('disable_relative_classname_inclusion')
|
68
|
+
```
|
69
|
+
|
70
|
+
### Relative class reference
|
71
|
+
|
72
|
+
#### What you have done
|
73
|
+
|
74
|
+
```puppet
|
75
|
+
Class['::foo'] -> Class['::bar']
|
76
|
+
```
|
77
|
+
|
39
78
|
#### What you should have done
|
40
79
|
|
41
80
|
```puppet
|
42
|
-
|
81
|
+
Class['foo'] -> Class['bar']
|
43
82
|
```
|
44
83
|
|
45
84
|
#### Disabling the check
|
46
85
|
|
47
|
-
To disable this check, you can add `--no-
|
86
|
+
To disable this check, you can add `--no-relative_classname_reference-check` to your puppet-lint command line.
|
48
87
|
|
49
88
|
```shell
|
50
|
-
$ puppet-lint --no-
|
89
|
+
$ puppet-lint --no-relative_classname_reference-check path/to/file.pp
|
51
90
|
```
|
52
91
|
|
53
92
|
Alternatively, if you’re calling puppet-lint via the Rake task, you should insert the following line to your `Rakefile`.
|
54
93
|
|
55
94
|
```ruby
|
56
|
-
PuppetLint.configuration.send('
|
95
|
+
PuppetLint.configuration.send('disable_relative_classname_reference')
|
57
96
|
```
|
58
97
|
|
59
98
|
## Transfer Notice
|
@@ -63,3 +102,12 @@ The maintainer preferred that Puppet Community take ownership of the module for
|
|
63
102
|
Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.
|
64
103
|
|
65
104
|
Previously: https://github.com/camptocamp/puppet-lint-absolute_classname-check
|
105
|
+
|
106
|
+
## Release information
|
107
|
+
|
108
|
+
To make a new release, please do:
|
109
|
+
* Update the version in the `puppet-lint-absolute_classname-check.gemspec` file
|
110
|
+
* Install gems with `bundle install --with release --path .vendor`
|
111
|
+
* generate the changelog with `bundle exec rake changelog`
|
112
|
+
* Create a PR with it
|
113
|
+
* 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
|
5
|
-
next if resource_indexes.any? { |resource| resource[:tokens].include?(token) }
|
6
|
+
if [:NAME,:FUNCTION_NAME].include?(token.type) && ['include','contain','require'].include?(token.value)
|
6
7
|
s = token.next_code_token
|
8
|
+
next if s.nil?
|
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
|
|
@@ -79,6 +89,23 @@ describe 'relative_classname_inclusion' do
|
|
79
89
|
expect(problems).to have(0).problems
|
80
90
|
end
|
81
91
|
end
|
92
|
+
|
93
|
+
context 'when require is a hash key' do
|
94
|
+
let(:code) do
|
95
|
+
<<-EOS
|
96
|
+
$defaults = {
|
97
|
+
require => Exec['apt_update'],
|
98
|
+
}
|
99
|
+
$defaults = {
|
100
|
+
'require' => Exec['apt_update'],
|
101
|
+
}
|
102
|
+
EOS
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should detect no problems' do
|
106
|
+
expect(problems).to have(0).problems
|
107
|
+
end
|
108
|
+
end
|
82
109
|
end
|
83
110
|
|
84
111
|
context 'with fix enabled' do
|
@@ -115,11 +142,61 @@ describe 'relative_classname_inclusion' do
|
|
115
142
|
require('::foobar')
|
116
143
|
require(foobar(baz))
|
117
144
|
require(foobar('baz'))
|
145
|
+
|
146
|
+
class foobar inherits ::baz {
|
147
|
+
}
|
118
148
|
EOS
|
119
149
|
end
|
120
150
|
|
121
|
-
it 'should
|
122
|
-
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
|
+
)
|
123
200
|
end
|
124
201
|
end
|
125
202
|
|
@@ -133,36 +210,28 @@ describe 'relative_classname_inclusion' do
|
|
133
210
|
contain(foobar)
|
134
211
|
require foobar
|
135
212
|
require(foobar)
|
213
|
+
class foobar inherits baz {
|
214
|
+
}
|
136
215
|
EOS
|
137
216
|
end
|
138
217
|
|
139
|
-
it 'should detect
|
140
|
-
expect(problems).to have(
|
218
|
+
it 'should not detect any problems' do
|
219
|
+
expect(problems).to have(0).problems
|
141
220
|
end
|
221
|
+
end
|
222
|
+
end
|
142
223
|
|
143
|
-
|
144
|
-
|
145
|
-
expect(problems).to contain_fixed(msg).on_line(2).in_column(17)
|
146
|
-
expect(problems).to contain_fixed(msg).on_line(3).in_column(17)
|
147
|
-
expect(problems).to contain_fixed(msg).on_line(4).in_column(17)
|
148
|
-
expect(problems).to contain_fixed(msg).on_line(5).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(7).in_column(17)
|
151
|
-
end
|
224
|
+
describe '(#12) behavior of lookup("foo", {merge => unique}).include' do
|
225
|
+
let(:msg) { '(#12) class included with lookup("foo", {merge => unique}).include' }
|
152
226
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
require ::foobar
|
162
|
-
require(::foobar)
|
163
|
-
EOS
|
164
|
-
)
|
165
|
-
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
|
166
235
|
end
|
167
236
|
end
|
168
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.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: 2020-10-24 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.0.8
|
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
|
-
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|
158
142
|
- spec/spec_helper.rb
|
143
|
+
- spec/puppet-lint/plugins/check_classname_reference/relative_classname_reference_spec.rb
|
144
|
+
- spec/puppet-lint/plugins/check_absolute_classname/relative_classname_inclusion_spec.rb
|