puppet-lint-param_comment-check 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57edfb5e9c1716c1bfb583619d1a36bf57f7f4492af64f33a828dba5f4b1eec2
4
- data.tar.gz: 3350c35a78495a1d4de4f25567af5da91cbed2601c25e3fe8e13e273e31e8f09
3
+ metadata.gz: bc1677e0675072c3a48173655360a1daca9c0539ff2a58bd4f71a7c05f38e37b
4
+ data.tar.gz: af924c9a20e1957f117538c80cc9a7fa3aa89dcdfafbb2d9b85b26990855e851
5
5
  SHA512:
6
- metadata.gz: 0e58accb1fe706bb94f24ccbe8ed80f50aee634f942360f4b29c203a206c84a7196fc0bda9c882561f7d2b9420919d703fb7444a41ac47da9d3c4a998d54ae48
7
- data.tar.gz: 10e7eef3b38f933c9f871e727d912c88e1fc76193158dd909c6c99e9d084dd585dce554dc5573d7eb206170b2d07c7fbe530a888903e3ca15446d9fbb29fbdd7
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
- in_brackets = false
53
+ brackets = 0
54
54
  param_tokens.reject { |token| %i[WHITESPACE NEWLINE].include? token.type }.each do |token|
55
- in_brackets = true if token.type == :LBRACK
56
- in_brackets = false if token.type == :RBRACK
57
- next if in_brackets
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-param_comment-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Ploeger