puppet-lint 2.5.2 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +522 -0
- data/lib/puppet-lint/bin.rb +71 -6
- data/lib/puppet-lint/checkplugin.rb +43 -9
- data/lib/puppet-lint/checks.rb +16 -16
- data/lib/puppet-lint/configuration.rb +134 -134
- data/lib/puppet-lint/data.rb +28 -28
- data/lib/puppet-lint/lexer/string_slurper.rb +138 -140
- data/lib/puppet-lint/lexer/token.rb +188 -190
- data/lib/puppet-lint/lexer.rb +416 -417
- data/lib/puppet-lint/monkeypatches.rb +1 -1
- data/lib/puppet-lint/optparser.rb +5 -1
- data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +6 -4
- data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +6 -4
- data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/inherits_across_namespaces.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/names_containing_dash.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/names_containing_uppercase.rb +7 -5
- data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +7 -4
- data/lib/puppet-lint/plugins/check_classes/right_to_left_relationship.rb +5 -3
- data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +15 -13
- data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +9 -7
- data/lib/puppet-lint/plugins/check_comments/star_comments.rb +10 -8
- data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +6 -4
- data/lib/puppet-lint/plugins/check_conditionals/selector_inside_resource.rb +5 -3
- data/lib/puppet-lint/plugins/check_documentation/documentation.rb +7 -3
- data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +15 -11
- data/lib/puppet-lint/plugins/check_resources/duplicate_params.rb +5 -3
- data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +8 -5
- data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +11 -8
- data/lib/puppet-lint/plugins/check_resources/file_mode.rb +14 -9
- data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +11 -6
- data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +6 -4
- data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +12 -7
- data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +8 -6
- data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +14 -8
- data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +11 -7
- data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +11 -6
- data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +12 -8
- data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +11 -7
- data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +11 -7
- data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +3 -8
- data/lib/puppet-lint/plugins/check_whitespace/2sp_soft_tabs.rb +10 -8
- data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +3 -8
- data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +10 -8
- data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +11 -7
- data/lib/puppet-lint/plugins/check_whitespace/line_length.rb +29 -0
- data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +13 -7
- data/lib/puppet-lint/plugins.rb +60 -61
- data/lib/puppet-lint/report/github.rb +17 -0
- data/lib/puppet-lint/report/sarif_template.json +63 -0
- data/lib/puppet-lint/tasks/puppet-lint.rb +84 -83
- data/lib/puppet-lint/tasks/release_test.rb +4 -1
- data/lib/puppet-lint/version.rb +1 -1
- data/lib/puppet-lint.rb +27 -12
- data/spec/acceptance/puppet_lint_spec.rb +46 -0
- data/spec/spec_helper.rb +92 -91
- data/spec/spec_helper_acceptance.rb +6 -0
- data/spec/spec_helper_acceptance_local.rb +38 -0
- data/spec/{puppet-lint → unit/puppet-lint}/bin_spec.rb +79 -35
- data/spec/{puppet-lint → unit/puppet-lint}/checks_spec.rb +36 -36
- data/spec/unit/puppet-lint/configuration_spec.rb +88 -0
- data/spec/{puppet-lint → unit/puppet-lint}/data_spec.rb +6 -3
- data/spec/{puppet-lint → unit/puppet-lint}/ignore_overrides_spec.rb +17 -17
- data/spec/{puppet-lint → unit/puppet-lint}/lexer/string_slurper_spec.rb +128 -128
- data/spec/{puppet-lint → unit/puppet-lint}/lexer/token_spec.rb +1 -1
- data/spec/{puppet-lint → unit/puppet-lint}/lexer_spec.rb +653 -671
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/arrow_on_right_operand_line_spec.rb +16 -16
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/autoloader_layout_spec.rb +13 -13
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/class_inherits_from_params_class_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/code_on_top_scope_spec.rb +4 -4
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/inherits_across_namespaces_spec.rb +4 -4
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/name_contains_uppercase_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/names_containing_dash_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/nested_classes_or_defines_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/parameter_order_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/right_to_left_relationship_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_classes/variable_scope_spec.rb +25 -25
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/slash_comments_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_comments/star_comments_spec.rb +13 -13
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/case_without_default_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_conditionals/selector_inside_resource_spec.rb +3 -3
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_documentation/documentation_spec.rb +8 -8
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_nodes/unquoted_node_name_spec.rb +24 -24
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/duplicate_params_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_first_param_spec.rb +19 -19
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/ensure_not_symlink_target_spec.rb +10 -10
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/file_mode_spec.rb +40 -40
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_file_mode_spec.rb +20 -20
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_resource_title_spec.rb +24 -24
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/double_quoted_strings_spec.rb +27 -27
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/only_variable_string_spec.rb +18 -18
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/puppet_url_without_modules_spec.rb +9 -9
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/quoted_booleans_spec.rb +22 -22
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/single_quote_string_with_variables_spec.rb +2 -2
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/variables_not_enclosed_spec.rb +21 -21
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_contains_dash_spec.rb +6 -6
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_variables/variable_is_lowercase_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/140chars_spec.rb +5 -5
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/2sp_soft_tabs_spec.rb +2 -2
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/80chars_spec.rb +6 -6
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/arrow_alignment_spec.rb +127 -127
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/hard_tabs_spec.rb +7 -7
- data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_whitespace/trailing_whitespace_spec.rb +15 -15
- data/spec/unit/puppet-lint/puppet-lint_spec.rb +18 -0
- metadata +63 -119
- data/CHANGELOG.md +0 -33
- data/HISTORY.md +0 -1130
- data/spec/puppet-lint/configuration_spec.rb +0 -66
- data/spec/puppet-lint_spec.rb +0 -16
data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_file_mode_spec.rb
RENAMED
@@ -7,11 +7,11 @@ describe 'unquoted_file_mode' do
|
|
7
7
|
context '4 digit unquoted file mode' do
|
8
8
|
let(:code) { "file { 'foo': mode => 0777 }" }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'only detects a single problem' do
|
11
11
|
expect(problems).to have(1).problem
|
12
12
|
end
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'creates a warning' do
|
15
15
|
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
16
16
|
end
|
17
17
|
end
|
@@ -19,11 +19,11 @@ describe 'unquoted_file_mode' do
|
|
19
19
|
context '4 digit unquoted file mode' do
|
20
20
|
let(:code) { "concat { 'foo': mode => 0777 }" }
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'only detects a single problem' do
|
23
23
|
expect(problems).to have(1).problem
|
24
24
|
end
|
25
25
|
|
26
|
-
it '
|
26
|
+
it 'creates a warning' do
|
27
27
|
expect(problems).to contain_warning(msg).on_line(1).in_column(25)
|
28
28
|
end
|
29
29
|
end
|
@@ -31,7 +31,7 @@ describe 'unquoted_file_mode' do
|
|
31
31
|
context 'file mode from a function rvalue' do
|
32
32
|
let(:code) { "file { 'foo': mode => lookup('bar'), }" }
|
33
33
|
|
34
|
-
it '
|
34
|
+
it 'does not detect any problems' do
|
35
35
|
expect(problems).to have(0).problems
|
36
36
|
end
|
37
37
|
end
|
@@ -51,11 +51,11 @@ describe 'unquoted_file_mode' do
|
|
51
51
|
END
|
52
52
|
end
|
53
53
|
|
54
|
-
it '
|
54
|
+
it 'detects 3 problems' do
|
55
55
|
expect(problems).to have(3).problems
|
56
56
|
end
|
57
57
|
|
58
|
-
it '
|
58
|
+
it 'creates three warnings' do
|
59
59
|
expect(problems).to contain_warning(sprintf(msg)).on_line(4).in_column(23)
|
60
60
|
expect(problems).to contain_warning(sprintf(msg)).on_line(6).in_column(23)
|
61
61
|
expect(problems).to contain_warning(sprintf(msg)).on_line(8).in_column(23)
|
@@ -64,26 +64,26 @@ describe 'unquoted_file_mode' do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
context 'with fix enabled' do
|
67
|
-
before do
|
67
|
+
before(:each) do
|
68
68
|
PuppetLint.configuration.fix = true
|
69
69
|
end
|
70
70
|
|
71
|
-
after do
|
71
|
+
after(:each) do
|
72
72
|
PuppetLint.configuration.fix = false
|
73
73
|
end
|
74
74
|
|
75
75
|
context '4 digit unquoted file mode w/fix' do
|
76
76
|
let(:code) { "file { 'foo': mode => 0777 }" }
|
77
77
|
|
78
|
-
it '
|
78
|
+
it 'only detects a single problem' do
|
79
79
|
expect(problems).to have(1).problem
|
80
80
|
end
|
81
81
|
|
82
|
-
it '
|
82
|
+
it 'fixes the manifest' do
|
83
83
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(23)
|
84
84
|
end
|
85
85
|
|
86
|
-
it '
|
86
|
+
it 'single quotes the file mode' do
|
87
87
|
expect(manifest).to eq("file { 'foo': mode => '0777' }")
|
88
88
|
end
|
89
89
|
end
|
@@ -91,15 +91,15 @@ describe 'unquoted_file_mode' do
|
|
91
91
|
context '4 digit unquoted file mode w/fix' do
|
92
92
|
let(:code) { "concat { 'foo': mode => 0777 }" }
|
93
93
|
|
94
|
-
it '
|
94
|
+
it 'only detects a single problem' do
|
95
95
|
expect(problems).to have(1).problem
|
96
96
|
end
|
97
97
|
|
98
|
-
it '
|
98
|
+
it 'fixes the manifest' do
|
99
99
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(25)
|
100
100
|
end
|
101
101
|
|
102
|
-
it '
|
102
|
+
it 'single quotes the file mode' do
|
103
103
|
expect(manifest).to eq("concat { 'foo': mode => '0777' }")
|
104
104
|
end
|
105
105
|
end
|
@@ -107,11 +107,11 @@ describe 'unquoted_file_mode' do
|
|
107
107
|
context 'file mode from a function rvalue' do
|
108
108
|
let(:code) { "file { 'foo': mode => lookup('bar'), }" }
|
109
109
|
|
110
|
-
it '
|
110
|
+
it 'does not detect any problems' do
|
111
111
|
expect(problems).to have(0).problems
|
112
112
|
end
|
113
113
|
|
114
|
-
it '
|
114
|
+
it 'does not change the manifest' do
|
115
115
|
expect(manifest).to eq(code)
|
116
116
|
end
|
117
117
|
end
|
@@ -145,17 +145,17 @@ describe 'unquoted_file_mode' do
|
|
145
145
|
END
|
146
146
|
end
|
147
147
|
|
148
|
-
it '
|
148
|
+
it 'detects 3 problems' do
|
149
149
|
expect(problems).to have(3).problems
|
150
150
|
end
|
151
151
|
|
152
|
-
it '
|
152
|
+
it 'fixes 3 problems' do
|
153
153
|
expect(problems).to contain_fixed(msg).on_line(4).in_column(23)
|
154
154
|
expect(problems).to contain_fixed(msg).on_line(6).in_column(23)
|
155
155
|
expect(problems).to contain_fixed(msg).on_line(8).in_column(23)
|
156
156
|
end
|
157
157
|
|
158
|
-
it '
|
158
|
+
it 'quotes the file modes' do
|
159
159
|
expect(manifest).to eq(fixed)
|
160
160
|
end
|
161
161
|
end
|
data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_resources/unquoted_resource_title_spec.rb
RENAMED
@@ -7,7 +7,7 @@ describe 'unquoted_resource_title' do
|
|
7
7
|
context 'quoted resource title on single line resource' do
|
8
8
|
let(:code) { "file { 'foo': }" }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'does not detect any problems' do
|
11
11
|
expect(problems).to have(0).problems
|
12
12
|
end
|
13
13
|
end
|
@@ -15,11 +15,11 @@ describe 'unquoted_resource_title' do
|
|
15
15
|
context 'unquoted resource title on single line resource' do
|
16
16
|
let(:code) { 'file { foo: }' }
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'only detects a single problem' do
|
19
19
|
expect(problems).to have(1).problem
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'creates a warning' do
|
23
23
|
expect(problems).to contain_warning(msg).on_line(1).in_column(8)
|
24
24
|
end
|
25
25
|
end
|
@@ -32,7 +32,7 @@ describe 'unquoted_resource_title' do
|
|
32
32
|
END
|
33
33
|
end
|
34
34
|
|
35
|
-
it '
|
35
|
+
it 'does not detect any problems' do
|
36
36
|
expect(problems).to have(0).problems
|
37
37
|
end
|
38
38
|
end
|
@@ -45,11 +45,11 @@ describe 'unquoted_resource_title' do
|
|
45
45
|
END
|
46
46
|
end
|
47
47
|
|
48
|
-
it '
|
48
|
+
it 'only detects a single problem' do
|
49
49
|
expect(problems).to have(1).problem
|
50
50
|
end
|
51
51
|
|
52
|
-
it '
|
52
|
+
it 'creates a warning' do
|
53
53
|
expect(problems).to contain_warning(msg).on_line(1).in_column(18)
|
54
54
|
end
|
55
55
|
end
|
@@ -64,7 +64,7 @@ describe 'unquoted_resource_title' do
|
|
64
64
|
END
|
65
65
|
end
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'does not detect any problems' do
|
68
68
|
expect(problems).to have(0).problems
|
69
69
|
end
|
70
70
|
end
|
@@ -79,11 +79,11 @@ describe 'unquoted_resource_title' do
|
|
79
79
|
END
|
80
80
|
end
|
81
81
|
|
82
|
-
it '
|
82
|
+
it 'only detects a single problem' do
|
83
83
|
expect(problems).to have(1).problem
|
84
84
|
end
|
85
85
|
|
86
|
-
it '
|
86
|
+
it 'creates a warning' do
|
87
87
|
expect(problems).to contain_warning(msg).on_line(3).in_column(13)
|
88
88
|
end
|
89
89
|
end
|
@@ -91,7 +91,7 @@ describe 'unquoted_resource_title' do
|
|
91
91
|
context 'single line resource with an array of titles (all quoted)' do
|
92
92
|
let(:code) { "file { ['foo', 'bar']: }" }
|
93
93
|
|
94
|
-
it '
|
94
|
+
it 'does not detect any problems' do
|
95
95
|
expect(problems).to have(0).problems
|
96
96
|
end
|
97
97
|
end
|
@@ -109,7 +109,7 @@ describe 'unquoted_resource_title' do
|
|
109
109
|
END
|
110
110
|
end
|
111
111
|
|
112
|
-
it '
|
112
|
+
it 'does not detect any problems' do
|
113
113
|
expect(problems).to have(0).problems
|
114
114
|
end
|
115
115
|
end
|
@@ -124,7 +124,7 @@ describe 'unquoted_resource_title' do
|
|
124
124
|
END
|
125
125
|
end
|
126
126
|
|
127
|
-
it '
|
127
|
+
it 'does not detect any problems' do
|
128
128
|
expect(problems).to have(0).problems
|
129
129
|
end
|
130
130
|
end
|
@@ -146,33 +146,33 @@ describe 'unquoted_resource_title' do
|
|
146
146
|
END
|
147
147
|
end
|
148
148
|
|
149
|
-
it '
|
149
|
+
it 'does not detect any problems' do
|
150
150
|
expect(problems).to have(0).problems
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
context 'with fix enabled' do
|
156
|
-
before do
|
156
|
+
before(:each) do
|
157
157
|
PuppetLint.configuration.fix = true
|
158
158
|
end
|
159
159
|
|
160
|
-
after do
|
160
|
+
after(:each) do
|
161
161
|
PuppetLint.configuration.fix = false
|
162
162
|
end
|
163
163
|
|
164
164
|
context 'unquoted resource title on single line resource' do
|
165
165
|
let(:code) { 'file { foo: }' }
|
166
166
|
|
167
|
-
it '
|
167
|
+
it 'only detects a single problem' do
|
168
168
|
expect(problems).to have(1).problem
|
169
169
|
end
|
170
170
|
|
171
|
-
it '
|
171
|
+
it 'fixes the manifest' do
|
172
172
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(8)
|
173
173
|
end
|
174
174
|
|
175
|
-
it '
|
175
|
+
it 'singles quote the resource title' do
|
176
176
|
expect(manifest).to eq("file { 'foo': }")
|
177
177
|
end
|
178
178
|
end
|
@@ -192,15 +192,15 @@ describe 'unquoted_resource_title' do
|
|
192
192
|
END
|
193
193
|
end
|
194
194
|
|
195
|
-
it '
|
195
|
+
it 'only detects a single problem' do
|
196
196
|
expect(problems).to have(1).problem
|
197
197
|
end
|
198
198
|
|
199
|
-
it '
|
199
|
+
it 'fixes the manifest' do
|
200
200
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(18)
|
201
201
|
end
|
202
202
|
|
203
|
-
it '
|
203
|
+
it 'singles quote the resource title' do
|
204
204
|
expect(manifest).to eq(fixed)
|
205
205
|
end
|
206
206
|
end
|
@@ -224,15 +224,15 @@ describe 'unquoted_resource_title' do
|
|
224
224
|
END
|
225
225
|
end
|
226
226
|
|
227
|
-
it '
|
227
|
+
it 'only detects a single problem' do
|
228
228
|
expect(problems).to have(1).problem
|
229
229
|
end
|
230
230
|
|
231
|
-
it '
|
231
|
+
it 'fixes the manifest' do
|
232
232
|
expect(problems).to contain_fixed(msg).on_line(3).in_column(13)
|
233
233
|
end
|
234
234
|
|
235
|
-
it '
|
235
|
+
it 'singles quote the resource title' do
|
236
236
|
expect(manifest).to eq(fixed)
|
237
237
|
end
|
238
238
|
end
|
data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/double_quoted_strings_spec.rb
RENAMED
@@ -7,7 +7,7 @@ describe 'double_quoted_strings' do
|
|
7
7
|
context 'double quoted string containing a variable inside single quotes' do
|
8
8
|
let(:code) { "exec { \"/usr/bin/wget -O - '${source}' | /usr/bin/apt-key add -\": }" }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'does not detect any problems' do
|
11
11
|
expect(problems).to have(0).problems
|
12
12
|
end
|
13
13
|
end
|
@@ -15,11 +15,11 @@ describe 'double_quoted_strings' do
|
|
15
15
|
context 'multiple strings in a line' do
|
16
16
|
let(:code) { "\"aoeu\" '${foo}'" }
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'only detects a single problem' do
|
19
19
|
expect(problems).to have(1).problem
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'creates a warning' do
|
23
23
|
expect(problems).to contain_warning(msg).on_line(1).in_column(1)
|
24
24
|
end
|
25
25
|
end
|
@@ -27,7 +27,7 @@ describe 'double_quoted_strings' do
|
|
27
27
|
context 'double quoted string nested in a single quoted string' do
|
28
28
|
let(:code) { "'grep \"status=sent\" /var/log/mail.log'" }
|
29
29
|
|
30
|
-
it '
|
30
|
+
it 'does not detect any problems' do
|
31
31
|
expect(problems).to have(0).problems
|
32
32
|
end
|
33
33
|
end
|
@@ -35,7 +35,7 @@ describe 'double_quoted_strings' do
|
|
35
35
|
context 'double quoted string after a comment' do
|
36
36
|
let(:code) { "service { 'foo': } # \"bar\"" }
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'does not detect any problems' do
|
39
39
|
expect(problems).to have(0).problems
|
40
40
|
end
|
41
41
|
end
|
@@ -43,7 +43,7 @@ describe 'double_quoted_strings' do
|
|
43
43
|
context 'double quoted string containing newline but no variables' do
|
44
44
|
let(:code) { %("foo\n") }
|
45
45
|
|
46
|
-
it '
|
46
|
+
it 'does not detect any problems' do
|
47
47
|
expect(problems).to have(0).problems
|
48
48
|
end
|
49
49
|
end
|
@@ -64,7 +64,7 @@ describe 'double_quoted_strings' do
|
|
64
64
|
END
|
65
65
|
end
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'does not detect any problems' do
|
68
68
|
expect(problems).to have(0).problems
|
69
69
|
end
|
70
70
|
end
|
@@ -72,11 +72,11 @@ describe 'double_quoted_strings' do
|
|
72
72
|
context 'double quoted true' do
|
73
73
|
let(:code) { "class { 'foo': boolFlag => \"true\" }" }
|
74
74
|
|
75
|
-
it '
|
75
|
+
it 'only detects a single problem' do
|
76
76
|
expect(problems).to have(1).problem
|
77
77
|
end
|
78
78
|
|
79
|
-
it '
|
79
|
+
it 'creates a warning' do
|
80
80
|
expect(problems).to contain_warning(msg).on_line(1).in_column(28)
|
81
81
|
end
|
82
82
|
end
|
@@ -84,11 +84,11 @@ describe 'double_quoted_strings' do
|
|
84
84
|
context 'double quoted false' do
|
85
85
|
let(:code) { "class { 'foo': boolFlag => \"false\" }" }
|
86
86
|
|
87
|
-
it '
|
87
|
+
it 'only detects a single problem' do
|
88
88
|
expect(problems).to have(1).problem
|
89
89
|
end
|
90
90
|
|
91
|
-
it '
|
91
|
+
it 'creates a warning' do
|
92
92
|
expect(problems).to contain_warning(msg).on_line(1).in_column(28)
|
93
93
|
end
|
94
94
|
end
|
@@ -107,7 +107,7 @@ describe 'double_quoted_strings' do
|
|
107
107
|
END
|
108
108
|
end
|
109
109
|
|
110
|
-
it '
|
110
|
+
it 'does not detect any problems' do
|
111
111
|
expect(problems).to have(0).problems
|
112
112
|
end
|
113
113
|
end
|
@@ -115,11 +115,11 @@ describe 'double_quoted_strings' do
|
|
115
115
|
context 'double quoted string with random escape should be rejected' do
|
116
116
|
let(:code) { %( $ztring = "this string contains \l random escape" ) }
|
117
117
|
|
118
|
-
it '
|
118
|
+
it 'only detects a single problem' do
|
119
119
|
expect(problems).to have(1).problem
|
120
120
|
end
|
121
121
|
|
122
|
-
it '
|
122
|
+
it 'creates a warning' do
|
123
123
|
expect(problems).to contain_warning(msg).on_line(1).in_column(12)
|
124
124
|
end
|
125
125
|
end
|
@@ -127,7 +127,7 @@ describe 'double_quoted_strings' do
|
|
127
127
|
context 'single quotes in a double quoted string' do
|
128
128
|
let(:code) { "\"this 'string' 'has' lots of 'quotes'\"" }
|
129
129
|
|
130
|
-
it '
|
130
|
+
it 'does not detect any problems' do
|
131
131
|
expect(problems).to have(0).problems
|
132
132
|
end
|
133
133
|
end
|
@@ -135,29 +135,29 @@ describe 'double_quoted_strings' do
|
|
135
135
|
context 'double quoted string containing single quoted string' do
|
136
136
|
let(:code) { %(notify { "'foo'": }) }
|
137
137
|
|
138
|
-
it '
|
138
|
+
it 'does not detect any problems' do
|
139
139
|
expect(problems).to have(0).problems
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
context 'with fix enabled' do
|
145
|
-
before do
|
145
|
+
before(:each) do
|
146
146
|
PuppetLint.configuration.fix = true
|
147
147
|
end
|
148
148
|
|
149
|
-
after do
|
149
|
+
after(:each) do
|
150
150
|
PuppetLint.configuration.fix = false
|
151
151
|
end
|
152
152
|
|
153
153
|
context 'double quoted string containing a variable inside single quotes' do
|
154
154
|
let(:code) { "exec { \"/usr/bin/wget -O - '${source}' | /usr/bin/apt-key add -\": }" }
|
155
155
|
|
156
|
-
it '
|
156
|
+
it 'does not detect any problems' do
|
157
157
|
expect(problems).to have(0).problems
|
158
158
|
end
|
159
159
|
|
160
|
-
it '
|
160
|
+
it 'does not modify the manifest' do
|
161
161
|
expect(manifest).to eq(code)
|
162
162
|
end
|
163
163
|
end
|
@@ -165,11 +165,11 @@ describe 'double_quoted_strings' do
|
|
165
165
|
context 'double quoted string containing a lone dollar' do
|
166
166
|
let(:code) { "\"sed -i 's/^;*[[:space:]]*${name}[[:space:]]*=.*$/${name} = ${value}/g' file\"" }
|
167
167
|
|
168
|
-
it '
|
168
|
+
it 'does not detect any problems' do
|
169
169
|
expect(problems).to have(0).problems
|
170
170
|
end
|
171
171
|
|
172
|
-
it '
|
172
|
+
it 'does not modify the manifest' do
|
173
173
|
expect(manifest).to eq(code)
|
174
174
|
end
|
175
175
|
end
|
@@ -177,15 +177,15 @@ describe 'double_quoted_strings' do
|
|
177
177
|
context 'multiple strings in a line' do
|
178
178
|
let(:code) { "\"aoeu\" '${foo}'" }
|
179
179
|
|
180
|
-
it '
|
180
|
+
it 'only detects a single problem' do
|
181
181
|
expect(problems).to have(1).problem
|
182
182
|
end
|
183
183
|
|
184
|
-
it '
|
184
|
+
it 'fixes the manifest' do
|
185
185
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(1)
|
186
186
|
end
|
187
187
|
|
188
|
-
it '
|
188
|
+
it 'converts the double quoted string into single quotes' do
|
189
189
|
expect(manifest).to eq("'aoeu' '${foo}'")
|
190
190
|
end
|
191
191
|
end
|
@@ -193,11 +193,11 @@ describe 'double_quoted_strings' do
|
|
193
193
|
context 'single quotes in a double quoted string' do
|
194
194
|
let(:code) { "\"this 'string' 'has' lots of 'quotes'\"" }
|
195
195
|
|
196
|
-
it '
|
196
|
+
it 'does not detect any problems' do
|
197
197
|
expect(problems).to have(0).problems
|
198
198
|
end
|
199
199
|
|
200
|
-
it '
|
200
|
+
it 'does not modify the manifest' do
|
201
201
|
expect(manifest).to eq(code)
|
202
202
|
end
|
203
203
|
end
|
data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/only_variable_string_spec.rb
RENAMED
@@ -7,11 +7,11 @@ describe 'only_variable_string' do
|
|
7
7
|
context 'string containing only a variable' do
|
8
8
|
let(:code) { '"${foo}"' }
|
9
9
|
|
10
|
-
it '
|
10
|
+
it 'only detects a single problem' do
|
11
11
|
expect(problems).to have(1).problem
|
12
12
|
end
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'creates a warning' do
|
15
15
|
expect(problems).to contain_warning(msg).on_line(1).in_column(4)
|
16
16
|
end
|
17
17
|
end
|
@@ -19,11 +19,11 @@ describe 'only_variable_string' do
|
|
19
19
|
context 'string containing only a variable w/ ref' do
|
20
20
|
let(:code) { '"${foo[0]}"' }
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'only detects a single problem' do
|
23
23
|
expect(problems).to have(1).problem
|
24
24
|
end
|
25
25
|
|
26
|
-
it '
|
26
|
+
it 'creates a warning' do
|
27
27
|
expect(problems).to contain_warning(msg).on_line(1).in_column(4)
|
28
28
|
end
|
29
29
|
end
|
@@ -31,11 +31,11 @@ describe 'only_variable_string' do
|
|
31
31
|
context 'string containing only a variable w/ lots of refs' do
|
32
32
|
let(:code) { '"${foo[0][aoeuaoeu][bar][999]}"' }
|
33
33
|
|
34
|
-
it '
|
34
|
+
it 'only detects a single problem' do
|
35
35
|
expect(problems).to have(1).problem
|
36
36
|
end
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'creates a warning' do
|
39
39
|
expect(problems).to contain_warning(msg).on_line(1).in_column(4)
|
40
40
|
end
|
41
41
|
end
|
@@ -50,33 +50,33 @@ describe 'only_variable_string' do
|
|
50
50
|
END
|
51
51
|
end
|
52
52
|
|
53
|
-
it '
|
53
|
+
it 'does not detect any problems' do
|
54
54
|
expect(problems).to be_empty
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
context 'with fix enabled' do
|
60
|
-
before do
|
60
|
+
before(:each) do
|
61
61
|
PuppetLint.configuration.fix = true
|
62
62
|
end
|
63
63
|
|
64
|
-
after do
|
64
|
+
after(:each) do
|
65
65
|
PuppetLint.configuration.fix = false
|
66
66
|
end
|
67
67
|
|
68
68
|
context 'string containing only a variable' do
|
69
69
|
let(:code) { '"${foo}"' }
|
70
70
|
|
71
|
-
it '
|
71
|
+
it 'only detects a single problem' do
|
72
72
|
expect(problems).to have(1).problem
|
73
73
|
end
|
74
74
|
|
75
|
-
it '
|
75
|
+
it 'fixes the manifest' do
|
76
76
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
|
77
77
|
end
|
78
78
|
|
79
|
-
it '
|
79
|
+
it 'unquotes the variable' do
|
80
80
|
expect(manifest).to eq('$foo')
|
81
81
|
end
|
82
82
|
end
|
@@ -84,15 +84,15 @@ describe 'only_variable_string' do
|
|
84
84
|
context 'string contaiting only a variable w/ ref' do
|
85
85
|
let(:code) { '"${foo[0]}"' }
|
86
86
|
|
87
|
-
it '
|
87
|
+
it 'only detects a single problem' do
|
88
88
|
expect(problems).to have(1).problem
|
89
89
|
end
|
90
90
|
|
91
|
-
it '
|
91
|
+
it 'fixes the manifest' do
|
92
92
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
|
93
93
|
end
|
94
94
|
|
95
|
-
it '
|
95
|
+
it 'unquotes the variable' do
|
96
96
|
expect(manifest).to eq('$foo[0]')
|
97
97
|
end
|
98
98
|
end
|
@@ -100,15 +100,15 @@ describe 'only_variable_string' do
|
|
100
100
|
context 'string containing only a variable w/ lots of refs' do
|
101
101
|
let(:code) { '"${foo[0][aoeuaoeu][bar][999]}"' }
|
102
102
|
|
103
|
-
it '
|
103
|
+
it 'only detects a single problem' do
|
104
104
|
expect(problems).to have(1).problem
|
105
105
|
end
|
106
106
|
|
107
|
-
it '
|
107
|
+
it 'fixes the manifest' do
|
108
108
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(4)
|
109
109
|
end
|
110
110
|
|
111
|
-
it '
|
111
|
+
it 'unquotes the variable' do
|
112
112
|
expect(manifest).to eq('$foo[0][aoeuaoeu][bar][999]')
|
113
113
|
end
|
114
114
|
end
|
data/spec/{puppet-lint → unit/puppet-lint}/plugins/check_strings/puppet_url_without_modules_spec.rb
RENAMED
@@ -6,7 +6,7 @@ describe 'puppet_url_without_modules' do
|
|
6
6
|
context 'puppet:// url with modules' do
|
7
7
|
let(:code) { "'puppet:///modules/foo'" }
|
8
8
|
|
9
|
-
it '
|
9
|
+
it 'does not detect any problems' do
|
10
10
|
expect(problems).to have(0).problems
|
11
11
|
end
|
12
12
|
end
|
@@ -15,37 +15,37 @@ describe 'puppet_url_without_modules' do
|
|
15
15
|
context 'puppet:// url without modules' do
|
16
16
|
let(:code) { "'puppet:///foo'" }
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'only detects a single problem' do
|
19
19
|
expect(problems).to have(1).problem
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'creates a warning' do
|
23
23
|
expect(problems).to contain_warning(msg).on_line(1).in_column(1)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'with fix enabled' do
|
29
|
-
before do
|
29
|
+
before(:each) do
|
30
30
|
PuppetLint.configuration.fix = true
|
31
31
|
end
|
32
32
|
|
33
|
-
after do
|
33
|
+
after(:each) do
|
34
34
|
PuppetLint.configuration.fix = false
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'puppet:// url without modules' do
|
38
38
|
let(:code) { "'puppet:///foo'" }
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'only detects a single problem' do
|
41
41
|
expect(problems).to have(1).problem
|
42
42
|
end
|
43
43
|
|
44
|
-
it '
|
44
|
+
it 'fixes the manifest' do
|
45
45
|
expect(problems).to contain_fixed(msg).on_line(1).in_column(1)
|
46
46
|
end
|
47
47
|
|
48
|
-
it '
|
48
|
+
it 'inserts modules into the path' do
|
49
49
|
expect(manifest).to eq("'puppet:///modules/foo'")
|
50
50
|
end
|
51
51
|
end
|
@@ -54,7 +54,7 @@ describe 'puppet_url_without_modules' do
|
|
54
54
|
context 'double string wrapped puppet:// urls' do
|
55
55
|
let(:code) { File.read('spec/fixtures/test/manifests/url_interpolation.pp') }
|
56
56
|
|
57
|
-
it '
|
57
|
+
it 'detects several problems' do
|
58
58
|
expect(problems).to have(4).problem
|
59
59
|
end
|
60
60
|
end
|