puppet-lint-params_empty_string-check 1.1.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: f0b1ae2ca9cbc0b49b97b104909cb97a363c7bf1ddf8f7ae81e5b84b3531baf1
4
- data.tar.gz: bc4060c86e7c065915f531310820024f956296cb9350f1e913aa785d2415f7ec
3
+ metadata.gz: bc4054f38eae4940d80dedcce753ad7b51cc74b0365d6c5182a7702fcd119289
4
+ data.tar.gz: c5e69036e9db4206ac149f8da17448b182393c0ebc36eede10b64536ae1df5a9
5
5
  SHA512:
6
- metadata.gz: 7678332af3be56c77a0df729cf04bbe7ac274fac48af489514e411711fbc6b2860a2d32ca2b7b97b2f4d5643a8b0d59d13b887fe9485085c1094e28703646021
7
- data.tar.gz: 197fac1823799ee83a51ed174c835f5e1aa5d880b7eac2c1124592eb37030cce5c8e041f0aca5e46db23a027858de7ff5fd54a1578ac5d3b2ef5a4950be07f61
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
- if type[0].type == :TYPE && type[0].value =~ /^(String|Variant)/ && default_value[0].type == :SSTRING && default_value[0].value == ''
17
- notify :warning, {
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 (:msg) { 'class parameter with String type defaults to empty string' }
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 (:code) {
8
+ let(:code) do
9
9
  <<-EOS
10
10
  class foo ( $bar = 'baz' ) { }
11
11
  EOS
12
- }
12
+ end
13
13
 
14
- it 'should not detect any problems' do
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 (:code) {
20
+ let(:code) do
21
21
  <<-EOS
22
22
  class foo ( String[0] $bar = '' ) { }
23
23
  EOS
24
- }
24
+ end
25
25
 
26
- it 'should detect one problem' do
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 (:code) {
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 'should detect one problem' do
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 (:code) {
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 'should detect one problem' do
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 (:code) {
56
+ let(:code) do
57
57
  <<-EOS
58
58
  class foo ( ) { $bar = 'baz' }
59
59
  EOS
60
- }
60
+ end
61
61
 
62
- it 'should not detect any problems' do
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 (:code) {
68
+ let(:code) do
69
69
  <<-EOS
70
70
  class foo ( String $bar = '' ) { }
71
71
  EOS
72
- }
72
+ end
73
73
 
74
- it 'should detect a single problem' do
74
+ it 'detects a single problem' do
75
75
  expect(problems).to have(1).problem
76
76
  end
77
77
 
78
- it 'should create a warning' do
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 (:code) {
84
+ let(:code) do
84
85
  <<-EOS
85
86
  class foo ( ) { $bar = '' }
86
87
  EOS
87
- }
88
+ end
88
89
 
89
- it 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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 (:code) {
108
+ let(:code) do
106
109
  <<-EOS
107
110
  class foo ( String $var = 'public' ) { }
108
111
  EOS
109
- }
112
+ end
110
113
 
111
- it 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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 (:code) {
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 'should not detect any problems' do
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-params_empty_string-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
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: 2023-02-24 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -16,90 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.5'
19
+ version: '3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4'
22
+ version: '5'
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
- version: '2.5'
29
+ version: '3'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '3.10'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3.10'
47
- - !ruby/object:Gem::Dependency
48
- name: rspec-its
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.3'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.3'
61
- - !ruby/object:Gem::Dependency
62
- name: rspec-collection_matchers
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.2'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.2'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec-json_expectations
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '2.2'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '2.2'
89
- - !ruby/object:Gem::Dependency
90
- name: rake
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
32
+ version: '5'
103
33
  description:
104
34
  email: voxpupuli@groups.io
105
35
  executables: []
@@ -108,7 +38,7 @@ extra_rdoc_files: []
108
38
  files:
109
39
  - LICENSE
110
40
  - README.md
111
- - lib/puppet-lint/plugins/check-params_empty_string_assignment.rb
41
+ - lib/puppet-lint/plugins/check_params_empty_string_assignment.rb
112
42
  - spec/puppet-lint/plugins/check_params_empty_string_assignment/check_params_empty_string_assignment_spec.rb
113
43
  - spec/spec_helper.rb
114
44
  homepage: https://github.com/voxpupuli/puppet-lint-params_empty_string-check
@@ -123,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
53
  requirements:
124
54
  - - ">="
125
55
  - !ruby/object:Gem::Version
126
- version: '0'
56
+ version: 2.7.0
127
57
  required_rubygems_version: !ruby/object:Gem::Requirement
128
58
  requirements:
129
59
  - - ">="
@@ -135,6 +65,4 @@ signing_key:
135
65
  specification_version: 4
136
66
  summary: A puppet-lint plugin to check for class parameters assigned to the empty
137
67
  string.
138
- test_files:
139
- - spec/puppet-lint/plugins/check_params_empty_string_assignment/check_params_empty_string_assignment_spec.rb
140
- - spec/spec_helper.rb
68
+ test_files: []