puppet-lint 0.1.9 → 0.1.10
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.
- data/Rakefile +19 -0
- data/bin/puppet-lint +33 -11
- data/lib/puppet-lint.rb +112 -33
- data/lib/puppet-lint/configuration.rb +57 -0
- data/lib/puppet-lint/plugin.rb +122 -11
- data/lib/puppet-lint/plugins/check_classes.rb +57 -68
- data/lib/puppet-lint/plugins/check_conditionals.rb +19 -22
- data/lib/puppet-lint/plugins/check_resources.rb +42 -32
- data/lib/puppet-lint/plugins/check_strings.rb +34 -18
- data/lib/puppet-lint/plugins/check_variables.rb +11 -6
- data/lib/puppet-lint/plugins/check_whitespace.rb +39 -11
- data/puppet-lint.gemspec +3 -1
- data/spec/puppet-lint/check_classes_spec.rb +59 -53
- data/spec/puppet-lint/check_conditionals_spec.rb +5 -9
- data/spec/puppet-lint/check_resources_spec.rb +36 -35
- data/spec/puppet-lint/check_strings_spec.rb +17 -27
- data/spec/puppet-lint/check_variables_spec.rb +8 -3
- data/spec/puppet-lint/check_whitespace_spec.rb +7 -13
- data/spec/spec_helper.rb +98 -0
- metadata +19 -4
@@ -2,31 +2,59 @@
|
|
2
2
|
# http://docs.puppetlabs.com/guides/style_guide.html#spacing-indentation--whitespace
|
3
3
|
|
4
4
|
class PuppetLint::Plugins::CheckWhitespace < PuppetLint::CheckPlugin
|
5
|
-
|
5
|
+
check 'hard_tabs' do
|
6
6
|
line_no = 0
|
7
|
-
|
8
|
-
selectors = []
|
9
|
-
resource_indent_length = 0
|
10
|
-
data.split("\n").each do |line|
|
7
|
+
manifest_lines.each do |line|
|
11
8
|
line_no += 1
|
12
9
|
|
13
10
|
# MUST NOT use literal tab characters
|
14
|
-
error "tab character found
|
11
|
+
notify :error, :message => "tab character found", :linenumber => line_no if line.include? "\t"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
check 'trailing_whitespace' do
|
16
|
+
line_no = 0
|
17
|
+
manifest_lines.each do |line|
|
18
|
+
line_no += 1
|
15
19
|
|
16
20
|
# MUST NOT contain trailing white space
|
17
|
-
error "trailing whitespace found
|
21
|
+
notify :error, :message => "trailing whitespace found", :linenumber => line_no if line.end_with? " "
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
check '80chars' do
|
26
|
+
line_no = 0
|
27
|
+
manifest_lines.each do |line|
|
28
|
+
line_no += 1
|
18
29
|
|
19
30
|
# SHOULD NOT exceed an 80 character line width
|
20
31
|
unless line =~ /puppet:\/\//
|
21
|
-
|
32
|
+
notify :warning, :message => "line has more than 80 characters", :linenumber => line_no if line.length > 80
|
22
33
|
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
check '2sp_soft_tabs' do
|
38
|
+
line_no = 0
|
39
|
+
manifest_lines.each do |line|
|
40
|
+
line_no += 1
|
23
41
|
|
24
42
|
# MUST use two-space soft tabs
|
25
43
|
line.scan(/^ +/) do |prefix|
|
26
44
|
unless prefix.length % 2 == 0
|
27
|
-
error "two-space soft tabs not used
|
45
|
+
notify :error, :message => "two-space soft tabs not used", :linenumber => line_no
|
28
46
|
end
|
29
47
|
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
check 'arrow_alignment' do
|
52
|
+
line_no = 0
|
53
|
+
in_resource = false
|
54
|
+
selectors = []
|
55
|
+
resource_indent_length = 0
|
56
|
+
manifest_lines.each do |line|
|
57
|
+
line_no += 1
|
30
58
|
|
31
59
|
# SHOULD align fat comma arrows (=>) within blocks of attributes
|
32
60
|
if line =~ /^( +.+? +)=>/
|
@@ -39,7 +67,7 @@ class PuppetLint::Plugins::CheckWhitespace < PuppetLint::CheckPlugin
|
|
39
67
|
|
40
68
|
# check for length first
|
41
69
|
unless line_indent.length == selectors.last
|
42
|
-
|
70
|
+
notify :warning, :message => "=> on line isn't properly aligned for selector", :linenumber => line_no
|
43
71
|
end
|
44
72
|
|
45
73
|
# then for a new selector or selector finish
|
@@ -50,7 +78,7 @@ class PuppetLint::Plugins::CheckWhitespace < PuppetLint::CheckPlugin
|
|
50
78
|
end
|
51
79
|
else
|
52
80
|
unless line_indent.length == resource_indent_length
|
53
|
-
|
81
|
+
notify :warning, :message => "=> on line isn't properly aligned for resource", :linenumber => line_no
|
54
82
|
end
|
55
83
|
|
56
84
|
if line.strip.end_with? "{"
|
data/puppet-lint.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'puppet-lint'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.10'
|
4
4
|
s.homepage = 'https://github.com/rodjek/puppet-lint/'
|
5
5
|
s.summary = 'Ensure your Puppet manifests conform with the Puppetlabs style guide'
|
6
6
|
s.description = 'Checks your Puppet manifests against the Puppetlabs
|
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.executables = ['puppet-lint']
|
10
10
|
s.files = [
|
11
11
|
'bin/puppet-lint',
|
12
|
+
'lib/puppet-lint/configuration.rb',
|
12
13
|
'lib/puppet-lint/plugin.rb',
|
13
14
|
'lib/puppet-lint/plugins/check_classes.rb',
|
14
15
|
'lib/puppet-lint/plugins/check_conditionals.rb',
|
@@ -33,6 +34,7 @@ Gem::Specification.new do |s|
|
|
33
34
|
]
|
34
35
|
|
35
36
|
s.add_development_dependency 'rspec'
|
37
|
+
s.add_development_dependency 'rdoc'
|
36
38
|
|
37
39
|
s.authors = ['Tim Sharpe']
|
38
40
|
s.email = 'tim@sharpe.id.au'
|
@@ -3,29 +3,29 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckClasses do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.
|
6
|
+
klass.run(defined?(path).nil? ? '' : path, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'chain 2 resources left to right' do
|
11
11
|
let(:code) { "Class[foo] -> Class[bar]" }
|
12
12
|
|
13
|
-
its(:
|
14
|
-
its(:errors) { should be_empty }
|
13
|
+
its(:problems) { should be_empty }
|
15
14
|
end
|
16
15
|
|
17
16
|
describe 'chain 2 resources right to left' do
|
18
17
|
let(:code) { "Class[foo] <- Class[bar]" }
|
19
18
|
|
20
|
-
its(:
|
21
|
-
|
19
|
+
its(:problems) {
|
20
|
+
should have_problem :kind => :warning, :message => "right-to-left (<-) relationship", :linenumber => 1
|
21
|
+
should_not have_problem :kind => :error
|
22
|
+
}
|
22
23
|
end
|
23
24
|
|
24
25
|
describe 'class on its own' do
|
25
26
|
let(:code) { "class foo { }" }
|
26
27
|
|
27
|
-
its(:
|
28
|
-
its(:errors) { should be_empty }
|
28
|
+
its(:problems) { should be_empty }
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'class inside a class' do
|
@@ -36,8 +36,10 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
36
36
|
}"
|
37
37
|
}
|
38
38
|
|
39
|
-
its(:
|
40
|
-
|
39
|
+
its(:problems) {
|
40
|
+
should have_problem :kind => :warning, :message => "class defined inside a class", :linenumber => 3
|
41
|
+
should_not have_problem :kind => :error
|
42
|
+
}
|
41
43
|
end
|
42
44
|
|
43
45
|
describe 'define inside a class' do
|
@@ -48,50 +50,55 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
48
50
|
}"
|
49
51
|
}
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
its(:problems) {
|
54
|
+
should have_problem :kind => :warning, :message => "define defined inside a class", :linenumber => 3
|
55
|
+
should_not have_problem :kind => :error
|
56
|
+
}
|
53
57
|
end
|
54
58
|
|
55
59
|
describe 'class inheriting from its namespace' do
|
56
60
|
let(:code) { "class foo::bar inherits foo { }" }
|
57
61
|
|
58
|
-
its(:
|
59
|
-
its(:errors) { should be_empty }
|
62
|
+
its(:problems) { should be_empty }
|
60
63
|
end
|
61
64
|
|
62
65
|
describe 'class inheriting from another namespace' do
|
63
66
|
let(:code) { "class foo::bar inherits baz { }" }
|
64
67
|
|
65
|
-
its(:
|
66
|
-
|
68
|
+
its(:problems) {
|
69
|
+
should have_problem :kind => :warning, :message => "class inherits across namespaces", :linenumber => 1
|
70
|
+
should_not have_problem :kind => :error
|
71
|
+
}
|
67
72
|
end
|
68
73
|
|
69
74
|
describe 'class with attrs in order' do
|
70
75
|
let(:code) { "class foo($bar, $baz='gronk') { }" }
|
71
76
|
|
72
|
-
its(:
|
73
|
-
its(:errors) { should be_empty }
|
77
|
+
its(:problems) { should be_empty }
|
74
78
|
end
|
75
79
|
|
76
80
|
describe 'class with attrs out of order' do
|
77
81
|
let(:code) { "class foo($bar='baz', $gronk) { }" }
|
78
82
|
|
79
|
-
its(:
|
80
|
-
|
83
|
+
its(:problems) {
|
84
|
+
should have_problem :kind => :warning, :message => "optional parameter listed before required parameter", :linenumber => 1
|
85
|
+
should_not have_problem :kind => :error
|
86
|
+
}
|
81
87
|
end
|
82
88
|
|
83
89
|
describe 'define with attrs in order' do
|
84
90
|
let(:code) { "define foo($bar, $baz='gronk') { }" }
|
85
91
|
|
86
|
-
its(:
|
87
|
-
its(:errors) { should be_empty }
|
92
|
+
its(:problems) { should be_empty }
|
88
93
|
end
|
89
94
|
|
90
95
|
describe 'define with attrs out of order' do
|
91
96
|
let(:code) { "define foo($bar='baz', $gronk) { }" }
|
92
97
|
|
93
|
-
its(:
|
94
|
-
|
98
|
+
its(:problems) {
|
99
|
+
should have_problem :kind => :warning, :message => "optional parameter listed before required parameter", :linenumber => 1
|
100
|
+
should_not have_problem :kind => :error
|
101
|
+
}
|
95
102
|
end
|
96
103
|
|
97
104
|
describe 'class with no variables declared accessing top scope' do
|
@@ -101,8 +108,10 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
101
108
|
}"
|
102
109
|
}
|
103
110
|
|
104
|
-
its(:
|
105
|
-
|
111
|
+
its(:problems) {
|
112
|
+
should have_problem :kind => :warning, :message => "top-scope variable being used without an explicit namespace", :linenumber => 3
|
113
|
+
should_not have_problem :kind => :error
|
114
|
+
}
|
106
115
|
end
|
107
116
|
|
108
117
|
describe 'class with no variables declared accessing top scope explicitly' do
|
@@ -112,8 +121,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
112
121
|
}"
|
113
122
|
}
|
114
123
|
|
115
|
-
its(:
|
116
|
-
its(:errors) { should be_empty }
|
124
|
+
its(:problems) { should be_empty }
|
117
125
|
end
|
118
126
|
|
119
127
|
describe 'class with variables declared accessing local scope' do
|
@@ -124,8 +132,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
124
132
|
}"
|
125
133
|
}
|
126
134
|
|
127
|
-
its(:
|
128
|
-
its(:errors) { should be_empty }
|
135
|
+
its(:problems) { should be_empty }
|
129
136
|
end
|
130
137
|
|
131
138
|
describe 'class with parameters accessing local scope' do
|
@@ -135,8 +142,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
135
142
|
}"
|
136
143
|
}
|
137
144
|
|
138
|
-
its(:
|
139
|
-
its(:errors) { should be_empty }
|
145
|
+
its(:problems) { should be_empty }
|
140
146
|
end
|
141
147
|
|
142
148
|
describe 'defined type with no variables declared accessing top scope' do
|
@@ -146,8 +152,10 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
146
152
|
}"
|
147
153
|
}
|
148
154
|
|
149
|
-
its(:
|
150
|
-
|
155
|
+
its(:problems) {
|
156
|
+
should have_problem :kind => :warning, :message => "top-scope variable being used without an explicit namespace", :linenumber => 3
|
157
|
+
should_not have_problem :kind => :error
|
158
|
+
}
|
151
159
|
end
|
152
160
|
|
153
161
|
describe 'defined type with no variables declared accessing top scope explicitly' do
|
@@ -157,19 +165,20 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
157
165
|
}"
|
158
166
|
}
|
159
167
|
|
160
|
-
its(:
|
161
|
-
its(:errors) { should be_empty }
|
168
|
+
its(:problems) { should be_empty }
|
162
169
|
end
|
163
170
|
|
164
171
|
describe '$name should be auto defined' do
|
165
172
|
let(:code) { "
|
166
173
|
define foo() {
|
167
174
|
$bar = $name
|
175
|
+
$baz = $title
|
176
|
+
$gronk = $module_name
|
177
|
+
$meep = $1
|
168
178
|
}"
|
169
179
|
}
|
170
180
|
|
171
|
-
its(:
|
172
|
-
its(:errors) { should be_empty }
|
181
|
+
its(:problems) { should be_empty }
|
173
182
|
end
|
174
183
|
|
175
184
|
describe 'instantiating a parametised class inside a class' do
|
@@ -181,8 +190,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
181
190
|
}"
|
182
191
|
}
|
183
192
|
|
184
|
-
its(:
|
185
|
-
its(:errors) { should be_empty }
|
193
|
+
its(:problems) { should be_empty }
|
186
194
|
end
|
187
195
|
|
188
196
|
describe 'instantiating a parametised class inside a define' do
|
@@ -194,8 +202,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
194
202
|
}"
|
195
203
|
}
|
196
204
|
|
197
|
-
its(:
|
198
|
-
its(:errors) { should be_empty }
|
205
|
+
its(:problems) { should be_empty }
|
199
206
|
end
|
200
207
|
|
201
208
|
describe 'class/define parameter set to another variable' do
|
@@ -204,8 +211,7 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
204
211
|
}"
|
205
212
|
}
|
206
213
|
|
207
|
-
its(:
|
208
|
-
its(:errors) { should be_empty }
|
214
|
+
its(:problems) { should be_empty }
|
209
215
|
end
|
210
216
|
|
211
217
|
describe 'class/define parameter set to another variable with incorrect order' do
|
@@ -214,39 +220,39 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
214
220
|
}"
|
215
221
|
}
|
216
222
|
|
217
|
-
its(:
|
218
|
-
|
223
|
+
its(:problems) {
|
224
|
+
should have_problem :kind => :warning, :message => "optional parameter listed before required parameter", :linenumber => 2
|
225
|
+
should_not have_problem :kind => :error
|
226
|
+
}
|
219
227
|
end
|
220
228
|
|
221
229
|
describe 'foo::bar in foo/manifests/bar.pp' do
|
222
230
|
let(:code) { "class foo::bar { }" }
|
223
231
|
let(:path) { '/etc/puppet/modules/foo/manifests/bar.pp' }
|
224
232
|
|
225
|
-
its(:
|
226
|
-
its(:errors) { should be_empty }
|
233
|
+
its(:problems) { should be_empty }
|
227
234
|
end
|
228
235
|
|
229
236
|
describe 'foo::bar::baz in foo/manifests/bar/baz.pp' do
|
230
237
|
let(:code) { 'define foo::bar::baz() { }' }
|
231
238
|
let(:path) { '/etc/puppet/modules/foo/manifests/bar/baz.pp' }
|
232
239
|
|
233
|
-
its(:
|
234
|
-
its(:errors) { should be_empty }
|
240
|
+
its(:problems) { should be_empty }
|
235
241
|
end
|
236
242
|
|
237
243
|
describe 'foo in foo/manifests/init.pp' do
|
238
244
|
let(:code) { 'class foo { }' }
|
239
245
|
let(:path) { '/etc/puppet/modules/foo/manifests/init.pp' }
|
240
246
|
|
241
|
-
its(:
|
242
|
-
its(:errors) { should be_empty }
|
247
|
+
its(:problems) { should be_empty }
|
243
248
|
end
|
244
249
|
|
245
250
|
describe 'foo::bar in foo/manifests/init.pp' do
|
246
251
|
let(:code) { 'class foo::bar { }' }
|
247
252
|
let(:path) { '/etc/puppet/modules/foo/manifests/init.pp' }
|
248
253
|
|
249
|
-
its(:
|
250
|
-
|
254
|
+
its(:problems) {
|
255
|
+
should only_have_problem :kind => :error, :message => "foo::bar not in autoload module layout", :linenumber => 1
|
256
|
+
}
|
251
257
|
end
|
252
258
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckConditionals do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.
|
6
|
+
klass.run(defined?(path).nil? ? '' : path, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -17,8 +17,7 @@ describe PuppetLint::Plugins::CheckConditionals do
|
|
17
17
|
}"
|
18
18
|
}
|
19
19
|
|
20
|
-
its(:
|
21
|
-
its(:errors) { should be_empty }
|
20
|
+
its(:problems) { should only_have_problem :kind => :warning, :message => "selector inside resource block", :linenumber => 3 }
|
22
21
|
end
|
23
22
|
|
24
23
|
describe 'resource with a variable as a attr value' do
|
@@ -28,8 +27,7 @@ describe PuppetLint::Plugins::CheckConditionals do
|
|
28
27
|
}"
|
29
28
|
}
|
30
29
|
|
31
|
-
its(:
|
32
|
-
its(:errors) { should be_empty }
|
30
|
+
its(:problems) { should be_empty }
|
33
31
|
end
|
34
32
|
|
35
33
|
describe 'case statement with a default case' do
|
@@ -40,8 +38,7 @@ describe PuppetLint::Plugins::CheckConditionals do
|
|
40
38
|
}"
|
41
39
|
}
|
42
40
|
|
43
|
-
its(:
|
44
|
-
its(:errors) { should be_empty }
|
41
|
+
its(:problems) { should be_empty }
|
45
42
|
end
|
46
43
|
|
47
44
|
describe 'case statement without a default case' do
|
@@ -52,7 +49,6 @@ describe PuppetLint::Plugins::CheckConditionals do
|
|
52
49
|
}"
|
53
50
|
}
|
54
51
|
|
55
|
-
its(:
|
56
|
-
its(:errors) { should be_empty }
|
52
|
+
its(:problems) { should only_have_problem :kind => :warning, :message => "case statement without a default case", :linenumber => 2 }
|
57
53
|
end
|
58
54
|
end
|
@@ -3,36 +3,35 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckResources do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.
|
6
|
+
klass.run(defined?(path).nil? ? '' : path, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '3 digit file mode' do
|
11
11
|
let(:code) { "file { 'foo': mode => 777 }" }
|
12
12
|
|
13
|
-
its(:
|
14
|
-
|
13
|
+
its(:problems) {
|
14
|
+
should have_problem :kind => :warning, :message => "mode should be represented as a 4 digit octal value", :linenumber => 1
|
15
|
+
should_not have_problem :kind => :error
|
16
|
+
}
|
15
17
|
end
|
16
18
|
|
17
19
|
describe '4 digit file mode' do
|
18
20
|
let(:code) { "file { 'foo': mode => '0777' }" }
|
19
21
|
|
20
|
-
its(:
|
21
|
-
its(:errors) { should be_empty }
|
22
|
+
its(:problems) { should be_empty }
|
22
23
|
end
|
23
24
|
|
24
25
|
describe 'file mode as a variable' do
|
25
26
|
let(:code) { "file { 'foo': mode => $file_mode }" }
|
26
27
|
|
27
|
-
its(:
|
28
|
-
its(:errors) { should be_empty }
|
28
|
+
its(:problems) { should be_empty }
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'ensure as only attr in a single line resource' do
|
32
32
|
let(:code) { "file { 'foo': ensure => present }" }
|
33
33
|
|
34
|
-
its(:
|
35
|
-
its(:errors) { should be_empty }
|
34
|
+
its(:problems) { should be_empty }
|
36
35
|
end
|
37
36
|
|
38
37
|
describe 'ensure as only attr in a multi line resource' do
|
@@ -42,8 +41,7 @@ describe PuppetLint::Plugins::CheckResources do
|
|
42
41
|
}"
|
43
42
|
}
|
44
43
|
|
45
|
-
its(:
|
46
|
-
its(:errors) { should be_empty }
|
44
|
+
its(:problems) { should be_empty }
|
47
45
|
end
|
48
46
|
|
49
47
|
describe 'ensure as second attr in a multi line resource' do
|
@@ -54,8 +52,10 @@ describe PuppetLint::Plugins::CheckResources do
|
|
54
52
|
}"
|
55
53
|
}
|
56
54
|
|
57
|
-
its(:
|
58
|
-
|
55
|
+
its(:problems) {
|
56
|
+
should have_problem :kind => :warning, :message => "ensure found on line but it's not the first attribute", :linenumber => 4
|
57
|
+
should_not have_problem :kind => :error
|
58
|
+
}
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'ensure as first attr in a multi line resource' do
|
@@ -66,22 +66,22 @@ describe PuppetLint::Plugins::CheckResources do
|
|
66
66
|
}"
|
67
67
|
}
|
68
68
|
|
69
|
-
its(:
|
70
|
-
its(:errors) { should be_empty }
|
69
|
+
its(:problems) { should be_empty }
|
71
70
|
end
|
72
71
|
|
73
72
|
describe 'quoted resource title on single line resource' do
|
74
73
|
let(:code) { "file { 'foo': }" }
|
75
74
|
|
76
|
-
its(:
|
77
|
-
its(:errors) { should be_empty }
|
75
|
+
its(:problems) { should be_empty }
|
78
76
|
end
|
79
77
|
|
80
78
|
describe 'unquoted resource title on single line resource' do
|
81
79
|
let(:code) { "file { foo: }" }
|
82
80
|
|
83
|
-
its(:
|
84
|
-
|
81
|
+
its(:problems) {
|
82
|
+
should have_problem :kind => :warning, :message => "unquoted resource title", :linenumber => 1
|
83
|
+
should_not have_problem :kind => :error
|
84
|
+
}
|
85
85
|
end
|
86
86
|
|
87
87
|
describe 'quoted resource title on multi line resource' do
|
@@ -90,8 +90,7 @@ describe PuppetLint::Plugins::CheckResources do
|
|
90
90
|
}"
|
91
91
|
}
|
92
92
|
|
93
|
-
its(:
|
94
|
-
its(:errors) { should be_empty }
|
93
|
+
its(:problems) { should be_empty }
|
95
94
|
end
|
96
95
|
|
97
96
|
describe 'unquoted resource title on multi line resource' do
|
@@ -100,8 +99,10 @@ describe PuppetLint::Plugins::CheckResources do
|
|
100
99
|
}"
|
101
100
|
}
|
102
101
|
|
103
|
-
its(:
|
104
|
-
|
102
|
+
its(:problems) {
|
103
|
+
should have_problem :kind => :warning, :message => "unquoted resource title", :linenumber => 2
|
104
|
+
should_not have_problem :kind => :error
|
105
|
+
}
|
105
106
|
end
|
106
107
|
|
107
108
|
describe 'condensed resources with quoted titles' do
|
@@ -112,8 +113,7 @@ describe PuppetLint::Plugins::CheckResources do
|
|
112
113
|
}"
|
113
114
|
}
|
114
115
|
|
115
|
-
its(:
|
116
|
-
its(:errors) { should be_empty }
|
116
|
+
its(:problems) { should be_empty }
|
117
117
|
end
|
118
118
|
|
119
119
|
describe 'condensed resources with an unquoted title' do
|
@@ -124,15 +124,16 @@ describe PuppetLint::Plugins::CheckResources do
|
|
124
124
|
}"
|
125
125
|
}
|
126
126
|
|
127
|
-
its(:
|
128
|
-
|
127
|
+
its(:problems) {
|
128
|
+
should have_problem :kind => :warning, :message => "unquoted resource title", :linenumber => 4
|
129
|
+
should_not have_problem :kind => :error
|
130
|
+
}
|
129
131
|
end
|
130
132
|
|
131
133
|
describe 'single line resource with an array of titles (all quoted)' do
|
132
134
|
let(:code) { "file { ['foo', 'bar']: }" }
|
133
135
|
|
134
|
-
its(:
|
135
|
-
its(:errors) { should be_empty }
|
136
|
+
its(:problems) { should be_empty }
|
136
137
|
end
|
137
138
|
|
138
139
|
describe 'resource inside a case statement' do
|
@@ -146,8 +147,7 @@ describe PuppetLint::Plugins::CheckResources do
|
|
146
147
|
}"
|
147
148
|
}
|
148
149
|
|
149
|
-
its(:
|
150
|
-
its(:errors) { should be_empty }
|
150
|
+
its(:problems) { should be_empty }
|
151
151
|
end
|
152
152
|
|
153
153
|
describe 'file resource creating a symlink with seperate target attr' do
|
@@ -158,8 +158,7 @@ describe PuppetLint::Plugins::CheckResources do
|
|
158
158
|
}"
|
159
159
|
}
|
160
160
|
|
161
|
-
its(:
|
162
|
-
its(:errors) { should be_empty }
|
161
|
+
its(:problems) { should be_empty }
|
163
162
|
end
|
164
163
|
|
165
164
|
describe 'file resource creating a symlink with target specified in ensure' do
|
@@ -169,7 +168,9 @@ describe PuppetLint::Plugins::CheckResources do
|
|
169
168
|
}"
|
170
169
|
}
|
171
170
|
|
172
|
-
its(:
|
173
|
-
|
171
|
+
its(:problems) {
|
172
|
+
should have_problem :kind => :warning, :message => "symlink target specified in ensure attr", :linenumber => 3
|
173
|
+
should_not have_problem :kind => :error
|
174
|
+
}
|
174
175
|
end
|
175
176
|
end
|