puppet-lint-param_comment-check 0.1.2 → 0.1.3
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: bc1677e0675072c3a48173655360a1daca9c0539ff2a58bd4f71a7c05f38e37b
|
4
|
+
data.tar.gz: af924c9a20e1957f117538c80cc9a7fa3aa89dcdfafbb2d9b85b26990855e851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b99e9b40064843a160dfd7e44d81962ed2ee4fd0246b5a623cedc1cb632b9cbbb97645ae3c8ac4caf2d9236fd694dbbccabf56d49a1b12074e8618e69f7e76
|
7
|
+
data.tar.gz: f466b51ef27e5bcd8edff95fb434706c04b00351b3d6616913d9a5ee3d91004fc8b15614c50a8deb1e9cbeb14b3c67d45acb4d6b061bd7e80bc556e2d4996adf
|
@@ -50,11 +50,11 @@ end
|
|
50
50
|
def analyze_params(param_tokens) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
51
51
|
params = []
|
52
52
|
current_param = EMPTY_PARAM.dup
|
53
|
-
|
53
|
+
brackets = 0
|
54
54
|
param_tokens.reject { |token| %i[WHITESPACE NEWLINE].include? token.type }.each do |token|
|
55
|
-
|
56
|
-
|
57
|
-
next
|
55
|
+
brackets += 1 if token.type == :LBRACK
|
56
|
+
brackets -= 1 if token.type == :RBRACK
|
57
|
+
next unless brackets.zero?
|
58
58
|
|
59
59
|
current_param = analyze_param_token(token, current_param) unless token.type == :COMMA
|
60
60
|
if token.type == :COMMA
|
@@ -53,6 +53,30 @@ describe 'param_comment' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context 'valid code with complex type definition' do
|
57
|
+
let(:code) do
|
58
|
+
<<~CODE
|
59
|
+
# @summary
|
60
|
+
# some class
|
61
|
+
#
|
62
|
+
# @param optional
|
63
|
+
# Complicated
|
64
|
+
class my_class (
|
65
|
+
Optional[Hash[
|
66
|
+
String,
|
67
|
+
Struct[{
|
68
|
+
test => Optional[Boolean]
|
69
|
+
}]
|
70
|
+
]] $optional = undef
|
71
|
+
) {}
|
72
|
+
CODE
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should not detect any problems' do
|
76
|
+
expect(problems).to have(0).problems
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
56
80
|
context 'code with missing parameter comment' do
|
57
81
|
let(:code) do
|
58
82
|
<<~CODE
|
@@ -177,7 +201,7 @@ describe 'param_comment' do
|
|
177
201
|
end
|
178
202
|
|
179
203
|
it 'should create a warning' do
|
180
|
-
expect(problems).to contain_warning('Invalid param or hash option header')
|
204
|
+
expect(problems).to contain_warning('Invalid param or hash option header: @param mandatory A mandatory parameter')
|
181
205
|
.on_line(1)
|
182
206
|
.in_column(1)
|
183
207
|
end
|
@@ -273,7 +297,7 @@ describe 'param_comment' do
|
|
273
297
|
|
274
298
|
it 'should create a warning' do
|
275
299
|
expect(problems).to contain_warning(
|
276
|
-
'Invalid param or hash option header'
|
300
|
+
'Invalid param or hash option header: @option mandatory [Boolean] :some_option An option'
|
277
301
|
)
|
278
302
|
.on_line(3)
|
279
303
|
.in_column(1)
|