puppet-lint 0.2.0 → 0.2.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.
- data/lib/puppet-lint.rb +1 -3
- data/lib/puppet-lint/configuration.rb +7 -6
- data/lib/puppet-lint/plugin.rb +14 -24
- data/lib/puppet-lint/plugins/check_classes.rb +14 -10
- data/lib/puppet-lint/plugins/check_documentation.rb +10 -14
- data/lib/puppet-lint/plugins/check_resources.rb +56 -73
- data/lib/puppet-lint/version.rb +1 -1
- data/spec/puppet-lint/configuration_spec.rb +4 -1
- data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +51 -0
- data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +23 -0
- data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +45 -0
- data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +71 -0
- data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +67 -0
- data/spec/puppet-lint/plugins/check_classes/parameterised_classes_spec.rb +43 -0
- data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +23 -0
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +93 -0
- data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +16 -0
- data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +19 -0
- data/spec/puppet-lint/plugins/{check_conditionals_spec.rb → check_conditionals/case_without_default_spec.rb} +1 -39
- data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +33 -0
- data/spec/puppet-lint/plugins/{check_documentation_spec.rb → check_documentation/documentation_spec.rb} +1 -9
- data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +23 -0
- data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +43 -0
- data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +26 -0
- data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +43 -0
- data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +11 -0
- data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +110 -0
- data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +83 -0
- data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +16 -0
- data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +55 -0
- data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +16 -0
- data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +29 -0
- data/spec/puppet-lint/plugins/{check_variables_spec.rb → check_variables/variable_contains_dash_spec.rb} +1 -9
- data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +20 -0
- data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +38 -0
- data/spec/puppet-lint/plugins/{check_whitespace_spec.rb → check_whitespace/arrow_alignment_spec.rb} +1 -86
- data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +16 -0
- data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +16 -0
- data/spec/spec_helper.rb +17 -0
- metadata +122 -92
- data/spec/puppet-lint/plugins/check_classes_spec.rb +0 -390
- data/spec/puppet-lint/plugins/check_comments_spec.rb +0 -40
- data/spec/puppet-lint/plugins/check_resources_spec.rb +0 -249
- data/spec/puppet-lint/plugins/check_strings_spec.rb +0 -175
@@ -1,175 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PuppetLint::Plugins::CheckStrings do
|
4
|
-
subject do
|
5
|
-
klass = described_class.new
|
6
|
-
fileinfo = {}
|
7
|
-
fileinfo[:fullpath] = defined?(fullpath).nil? ? '' : fullpath
|
8
|
-
klass.run(fileinfo, code)
|
9
|
-
klass
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'double quoted string containing a variable insinde single quotes' do
|
13
|
-
let(:code) { "exec { \"/usr/bin/wget -O - '${source}' | /usr/bin/apt-key add -\": }" }
|
14
|
-
|
15
|
-
its(:problems) { should be_empty }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'multiple strings in a line' do
|
19
|
-
let(:code) { "\"aoeu\" '${foo}'" }
|
20
|
-
|
21
|
-
its(:problems) {
|
22
|
-
should have_problem({
|
23
|
-
:kind => :warning,
|
24
|
-
:message => 'double quoted string containing no variables',
|
25
|
-
:linenumber => 1,
|
26
|
-
:column => 1,
|
27
|
-
})
|
28
|
-
should have_problem({
|
29
|
-
:kind => :error,
|
30
|
-
:message => 'single quoted string containing a variable found',
|
31
|
-
:linenumber => 1,
|
32
|
-
:column => 8,
|
33
|
-
})
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'string containing only a variable' do
|
38
|
-
let(:code) { '"${foo}"' }
|
39
|
-
|
40
|
-
its(:problems) {
|
41
|
-
should only_have_problem({
|
42
|
-
:kind => :warning,
|
43
|
-
:message => 'string containing only a variable',
|
44
|
-
:linenumber => 1,
|
45
|
-
:column => 3,
|
46
|
-
})
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'variable not enclosed in {}' do
|
51
|
-
let(:code) { '" $gronk"' }
|
52
|
-
|
53
|
-
its(:problems) {
|
54
|
-
should only_have_problem({
|
55
|
-
:kind => :warning,
|
56
|
-
:message => 'variable not enclosed in {}',
|
57
|
-
:linenumber => 1,
|
58
|
-
:column => 3,
|
59
|
-
})
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'variable not enclosed in {} after many tokens' do
|
64
|
-
let(:code) { ("'groovy'\n" * 20) + '" $gronk"' }
|
65
|
-
|
66
|
-
its(:problems) {
|
67
|
-
should only_have_problem({
|
68
|
-
:kind => :warning,
|
69
|
-
:message => 'variable not enclosed in {}',
|
70
|
-
:linenumber => 21,
|
71
|
-
:column => 3,
|
72
|
-
})
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
describe 'double quoted string nested in a single quoted string' do
|
78
|
-
let(:code) { "'grep \"status=sent\" /var/log/mail.log'" }
|
79
|
-
|
80
|
-
its(:problems) { should be_empty }
|
81
|
-
end
|
82
|
-
|
83
|
-
describe 'double quoted string after a comment' do
|
84
|
-
let(:code) { "service { 'foo': } # \"bar\"" }
|
85
|
-
|
86
|
-
its(:problems) { should be_empty }
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'double quoted string containing newline but no variables' do
|
90
|
-
let(:code) { %{"foo\n"} }
|
91
|
-
|
92
|
-
its(:problems) { should be_empty }
|
93
|
-
end
|
94
|
-
|
95
|
-
describe 'quoted false' do
|
96
|
-
let(:code) { "class { 'foo': boolFlag => 'false' }" }
|
97
|
-
|
98
|
-
its(:problems) {
|
99
|
-
should only_have_problem({
|
100
|
-
:kind => :warning,
|
101
|
-
:message => 'quoted boolean value found',
|
102
|
-
:linenumber => 1,
|
103
|
-
:column => 28,
|
104
|
-
})
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
describe 'quoted true' do
|
109
|
-
let(:code) { "class { 'foo': boolFlag => 'true' }" }
|
110
|
-
|
111
|
-
its(:problems) {
|
112
|
-
should only_have_problem({
|
113
|
-
:kind => :warning,
|
114
|
-
:message => 'quoted boolean value found',
|
115
|
-
:linenumber => 1,
|
116
|
-
:column => 28,
|
117
|
-
})
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
describe 'double quoted true' do
|
122
|
-
let(:code) { "class { 'foo': boolFlag => \"true\" }" }
|
123
|
-
|
124
|
-
its(:problems) {
|
125
|
-
should have_problem({
|
126
|
-
:kind => :warning,
|
127
|
-
:message => 'quoted boolean value found',
|
128
|
-
:linenumber => 1,
|
129
|
-
:column => 28,
|
130
|
-
})
|
131
|
-
should have_problem({
|
132
|
-
:kind => :warning,
|
133
|
-
:message => 'double quoted string containing no variables',
|
134
|
-
:linenumber => 1,
|
135
|
-
:column => 28,
|
136
|
-
})
|
137
|
-
}
|
138
|
-
end
|
139
|
-
|
140
|
-
describe 'double quoted false' do
|
141
|
-
let(:code) { "class { 'foo': boolFlag => \"false\" }" }
|
142
|
-
|
143
|
-
its(:problems) {
|
144
|
-
should have_problem({
|
145
|
-
:kind => :warning,
|
146
|
-
:message => 'quoted boolean value found',
|
147
|
-
:linenumber => 1,
|
148
|
-
:column => 28,
|
149
|
-
})
|
150
|
-
should have_problem({
|
151
|
-
:kind => :warning,
|
152
|
-
:message => 'double quoted string containing no variables',
|
153
|
-
:linenumber => 1,
|
154
|
-
:column => 28,
|
155
|
-
})
|
156
|
-
}
|
157
|
-
end
|
158
|
-
|
159
|
-
describe 'double quoted string with backslash for continuation' do
|
160
|
-
let(:code) { %{
|
161
|
-
class puppet::master::maintenance (
|
162
|
-
) {
|
163
|
-
cron { 'puppet_master_reports_cleanup':
|
164
|
-
command => "/usr/bin/find /var/lib/puppet/reports -type f -mtime +15 \
|
165
|
-
-delete && /usr/bin/find /var/lib/puppet/reports -mindepth 1 \
|
166
|
-
-empty -type d -delete",
|
167
|
-
minute => '15',
|
168
|
-
hour => '5',
|
169
|
-
}
|
170
|
-
}
|
171
|
-
} }
|
172
|
-
|
173
|
-
its(:problems) { should == [] }
|
174
|
-
end
|
175
|
-
end
|