puppet-lint-params_empty_string-check 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc4054f38eae4940d80dedcce753ad7b51cc74b0365d6c5182a7702fcd119289
|
4
|
+
data.tar.gz: c5e69036e9db4206ac149f8da17448b182393c0ebc36eede10b64536ae1df5a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a248139911486573f757a898d26b619ab1fa7861ee35c4ef75de8d4aef372b46d6841b010a212fbade6cee231e53999b71add8f7db117e354a57c4f98b8a0a6
|
7
|
+
data.tar.gz: 626ed806c8d8411a60fc807e74a42bce4c95548ffeb93e27645c9e4cd32a16cbae9c7e7232f6d8a5b7b62f78f6d28ac1ba71c218bed796c4fbbb30062ffae6dd
|
@@ -11,15 +11,18 @@ PuppetLint.new_check(:params_empty_string_assignment) do
|
|
11
11
|
# why can those be empty?
|
12
12
|
next if type.empty?
|
13
13
|
next if default_value.empty?
|
14
|
+
|
14
15
|
# if the parameter has datatype String/String[]/Variant and a value of ''
|
15
16
|
# we filter for the puppet-lint type of the value (:SSTRING) to ignore strings with variables
|
16
|
-
|
17
|
-
|
18
|
-
:message => 'class parameter with String type defaults to empty string',
|
19
|
-
:line => param.line,
|
20
|
-
:column => param.column,
|
21
|
-
}
|
17
|
+
unless type[0].type == :TYPE && type[0].value =~ /^(String|Variant)/ && default_value[0].type == :SSTRING && default_value[0].value == ''
|
18
|
+
next
|
22
19
|
end
|
20
|
+
|
21
|
+
notify :warning, {
|
22
|
+
message: 'class parameter with String type defaults to empty string',
|
23
|
+
line: param.line,
|
24
|
+
column: param.column,
|
25
|
+
}
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -1,120 +1,124 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'params_empty_string_assignment' do
|
4
|
-
let
|
4
|
+
let(:msg) { 'class parameter with String type defaults to empty string' }
|
5
5
|
|
6
6
|
context 'with fix disabled' do
|
7
7
|
context 'class definition without empty strings' do
|
8
|
-
let
|
8
|
+
let(:code) do
|
9
9
|
<<-EOS
|
10
10
|
class foo ( $bar = 'baz' ) { }
|
11
11
|
EOS
|
12
|
-
|
12
|
+
end
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'does not detect any problems' do
|
15
15
|
expect(problems).to have(0).problems
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'class definition with empty strings and 0 as minimal string length' do
|
20
|
-
let
|
20
|
+
let(:code) do
|
21
21
|
<<-EOS
|
22
22
|
class foo ( String[0] $bar = '' ) { }
|
23
23
|
EOS
|
24
|
-
|
24
|
+
end
|
25
25
|
|
26
|
-
it '
|
26
|
+
it 'detects one problem' do
|
27
27
|
expect(problems).to have(1).problem
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'class definition with empty strings and loose Variant datatype 1' do
|
32
|
-
let
|
32
|
+
let(:code) do
|
33
33
|
<<-EOS
|
34
34
|
class foo ( Variant[String[0], Integer] $bar = '' ) { }
|
35
35
|
EOS
|
36
|
-
|
36
|
+
end
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'detects one problem' do
|
39
39
|
expect(problems).to have(1).problem
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'class definition with empty strings and loose Variant datatype 2' do
|
44
|
-
let
|
44
|
+
let(:code) do
|
45
45
|
<<-EOS
|
46
46
|
class foo ( Variant[Any, Optional] $bar = '' ) { }
|
47
47
|
EOS
|
48
|
-
|
48
|
+
end
|
49
49
|
|
50
|
-
it '
|
50
|
+
it 'detects one problem' do
|
51
51
|
expect(problems).to have(1).problem
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
context 'class internal variable without empty strings' do
|
56
|
-
let
|
56
|
+
let(:code) do
|
57
57
|
<<-EOS
|
58
58
|
class foo ( ) { $bar = 'baz' }
|
59
59
|
EOS
|
60
|
-
|
60
|
+
end
|
61
61
|
|
62
|
-
it '
|
62
|
+
it 'does not detect any problems' do
|
63
63
|
expect(problems).to have(0).problems
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'class definition with empty strings' do
|
68
|
-
let
|
68
|
+
let(:code) do
|
69
69
|
<<-EOS
|
70
70
|
class foo ( String $bar = '' ) { }
|
71
71
|
EOS
|
72
|
-
|
72
|
+
end
|
73
73
|
|
74
|
-
it '
|
74
|
+
it 'detects a single problem' do
|
75
75
|
expect(problems).to have(1).problem
|
76
76
|
end
|
77
77
|
|
78
|
-
it '
|
78
|
+
it 'creates a warning' do
|
79
79
|
expect(problems).to contain_warning(msg).on_line(1).in_column(28)
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
82
83
|
context 'class internal variable with empty strings' do
|
83
|
-
let
|
84
|
+
let(:code) do
|
84
85
|
<<-EOS
|
85
86
|
class foo ( ) { $bar = '' }
|
86
87
|
EOS
|
87
|
-
|
88
|
+
end
|
88
89
|
|
89
|
-
it '
|
90
|
+
it 'does not detect any problems' do
|
90
91
|
expect(problems).to have(0).problem
|
91
92
|
end
|
92
93
|
end
|
94
|
+
|
93
95
|
context 'class definition with value and minimal string length at 0' do
|
94
|
-
let
|
96
|
+
let(:code) do
|
95
97
|
<<-EOS
|
96
98
|
class foo ( String[0] $var = 'public' ) { }
|
97
99
|
EOS
|
98
|
-
|
100
|
+
end
|
99
101
|
|
100
|
-
it '
|
102
|
+
it 'does not detect any problems' do
|
101
103
|
expect(problems).to have(0).problem
|
102
104
|
end
|
103
105
|
end
|
106
|
+
|
104
107
|
context 'class definition with value and no minimal string length' do
|
105
|
-
let
|
108
|
+
let(:code) do
|
106
109
|
<<-EOS
|
107
110
|
class foo ( String $var = 'public' ) { }
|
108
111
|
EOS
|
109
|
-
|
112
|
+
end
|
110
113
|
|
111
|
-
it '
|
114
|
+
it 'does not detect any problems' do
|
112
115
|
expect(problems).to have(0).problem
|
113
116
|
end
|
114
117
|
end
|
118
|
+
|
115
119
|
# this usecase was reported on slack
|
116
120
|
context 'class definition with value and string interpolation and values' do
|
117
|
-
let
|
121
|
+
let(:code) do
|
118
122
|
<<-EOS
|
119
123
|
class foo (
|
120
124
|
String $install_path = 'bla',
|
@@ -123,15 +127,16 @@ describe 'params_empty_string_assignment' do
|
|
123
127
|
# code
|
124
128
|
}
|
125
129
|
EOS
|
126
|
-
|
130
|
+
end
|
127
131
|
|
128
|
-
it '
|
132
|
+
it 'does not detect any problems' do
|
129
133
|
expect(problems).to have(0).problem
|
130
134
|
end
|
131
135
|
end
|
136
|
+
|
132
137
|
# this usecase was reported on slack as well
|
133
138
|
context 'class definition with value and string interpolation and not all values' do
|
134
|
-
let
|
139
|
+
let(:code) do
|
135
140
|
<<-EOS
|
136
141
|
class foo (
|
137
142
|
String $install_path,
|
@@ -140,15 +145,16 @@ describe 'params_empty_string_assignment' do
|
|
140
145
|
# code
|
141
146
|
}
|
142
147
|
EOS
|
143
|
-
|
148
|
+
end
|
144
149
|
|
145
|
-
it '
|
150
|
+
it 'does not detect any problems' do
|
146
151
|
expect(problems).to have(0).problem
|
147
152
|
end
|
148
153
|
end
|
154
|
+
|
149
155
|
# this usecase was reported on slack as well
|
150
156
|
context 'class definition with value and string interpolation and not all values and types' do
|
151
|
-
let
|
157
|
+
let(:code) do
|
152
158
|
<<-EOS
|
153
159
|
class foo (
|
154
160
|
String $install_path,
|
@@ -157,15 +163,16 @@ describe 'params_empty_string_assignment' do
|
|
157
163
|
# code
|
158
164
|
}
|
159
165
|
EOS
|
160
|
-
|
166
|
+
end
|
161
167
|
|
162
|
-
it '
|
168
|
+
it 'does not detect any problems' do
|
163
169
|
expect(problems).to have(0).problem
|
164
170
|
end
|
165
171
|
end
|
172
|
+
|
166
173
|
# this usecase was reported on slack as well
|
167
174
|
context 'class definition with value and string interpolation and not all values and types' do
|
168
|
-
let
|
175
|
+
let(:code) do
|
169
176
|
<<-EOS
|
170
177
|
define bar::foo (
|
171
178
|
String $install_path,
|
@@ -174,15 +181,16 @@ describe 'params_empty_string_assignment' do
|
|
174
181
|
# code
|
175
182
|
}
|
176
183
|
EOS
|
177
|
-
|
184
|
+
end
|
178
185
|
|
179
|
-
it '
|
186
|
+
it 'does not detect any problems' do
|
180
187
|
expect(problems).to have(0).problem
|
181
188
|
end
|
182
189
|
end
|
190
|
+
|
183
191
|
# this usecase was reported on slack as well
|
184
192
|
context 'class definition with value and string interpolation and not all values and types' do
|
185
|
-
let
|
193
|
+
let(:code) do
|
186
194
|
<<-EOS
|
187
195
|
define profiles::host_api::nexus::managed::gem_installation (
|
188
196
|
String $gem_source,
|
@@ -197,9 +205,9 @@ describe 'params_empty_string_assignment' do
|
|
197
205
|
# code
|
198
206
|
}
|
199
207
|
EOS
|
200
|
-
|
208
|
+
end
|
201
209
|
|
202
|
-
it '
|
210
|
+
it 'does not detect any problems' do
|
203
211
|
expect(problems).to have(0).problem
|
204
212
|
end
|
205
213
|
end
|
metadata
CHANGED
@@ -1,99 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-params_empty_string-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.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: 2023-04-21 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
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.5'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.5'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.10'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.10'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec-its
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.3'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.3'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-collection_matchers
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.2'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
17
|
+
- - ">="
|
67
18
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
-
|
70
|
-
name: rspec-json_expectations
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
19
|
+
version: '3'
|
20
|
+
- - "<"
|
74
21
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
-
type: :
|
22
|
+
version: '5'
|
23
|
+
type: :runtime
|
77
24
|
prerelease: false
|
78
25
|
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '2.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
26
|
requirements:
|
87
27
|
- - ">="
|
88
28
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
29
|
+
version: '3'
|
30
|
+
- - "<"
|
95
31
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
32
|
+
version: '5'
|
97
33
|
description:
|
98
34
|
email: voxpupuli@groups.io
|
99
35
|
executables: []
|
@@ -102,7 +38,7 @@ extra_rdoc_files: []
|
|
102
38
|
files:
|
103
39
|
- LICENSE
|
104
40
|
- README.md
|
105
|
-
- lib/puppet-lint/plugins/
|
41
|
+
- lib/puppet-lint/plugins/check_params_empty_string_assignment.rb
|
106
42
|
- spec/puppet-lint/plugins/check_params_empty_string_assignment/check_params_empty_string_assignment_spec.rb
|
107
43
|
- spec/spec_helper.rb
|
108
44
|
homepage: https://github.com/voxpupuli/puppet-lint-params_empty_string-check
|
@@ -117,18 +53,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
53
|
requirements:
|
118
54
|
- - ">="
|
119
55
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
56
|
+
version: 2.7.0
|
121
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
58
|
requirements:
|
123
59
|
- - ">="
|
124
60
|
- !ruby/object:Gem::Version
|
125
61
|
version: '0'
|
126
62
|
requirements: []
|
127
|
-
rubygems_version: 3.2.
|
63
|
+
rubygems_version: 3.2.33
|
128
64
|
signing_key:
|
129
65
|
specification_version: 4
|
130
66
|
summary: A puppet-lint plugin to check for class parameters assigned to the empty
|
131
67
|
string.
|
132
|
-
test_files:
|
133
|
-
- spec/puppet-lint/plugins/check_params_empty_string_assignment/check_params_empty_string_assignment_spec.rb
|
134
|
-
- spec/spec_helper.rb
|
68
|
+
test_files: []
|