puppet-lint-param_comment-check 0.1.4 → 0.1.5

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: 760c2ecbb41952244ece53d7fddafcc91f322300b512a65dfc4d5ab7b5622636
4
- data.tar.gz: 187d476c9e3418c03935d00ddf84fd9c9618cd8ac4a14a391e0046f68f92221f
3
+ metadata.gz: 637cfc1953d7f93cd5a8d160e90d7abeaf93efd0a1eafbf651dca61259fb6668
4
+ data.tar.gz: 7d74686774590de42d926b2e1a952330a1613e2b3724a8aac531d5003d3916a8
5
5
  SHA512:
6
- metadata.gz: 8396f55b48c7cd1e82f66855eb950c2c1fd4e908423625a262e6ba11496d2cd3b9c90931c66deb97efba5d706502416e71ef4ae47f7d459b5c0fcf24d7b86ef4
7
- data.tar.gz: '08c1d478a70c0a204805844aa0ad1724ee7a371852c3f7059596204d3c62f89d9044fa2cf44b26b6df2731331f371765b3cdf86de148ecf5cab88216336dea93'
6
+ metadata.gz: d67851be5623ec31c85ff025c13420e8535915d7f9df8d6e8c153df4e7f51c3874253a5dcdf87b30ccab4841a31501f91ab98989d40e30717ede4317dd55da18
7
+ data.tar.gz: f47b461b2b56d68e9792be6c8da580f4f4222960364ef165d72fe867007e0a2335adcffe5898b978c386141c0b374c10228f9a7257971fbd11374b765666f2f5
@@ -18,12 +18,14 @@ EMPTY_PARAM = {
18
18
  # @return The head comments
19
19
  def get_comments(tokens, token_start)
20
20
  comments = []
21
- token_pointer = token_start
21
+ token_pointer = token_start - 1
22
22
  while token_pointer >= 0
23
- comments.append(tokens[token_pointer]) if tokens[token_pointer].type == :COMMENT
23
+ break unless %i[COMMENT NEWLINE].include? tokens[token_pointer].type
24
+
25
+ comments.append(tokens[token_pointer])
24
26
  token_pointer -= 1
25
27
  end
26
- comments.reverse
28
+ comments.reject { |comment| comment.type == :NEWLINE }.reverse
27
29
  end
28
30
 
29
31
  # Analyze a parameter token
@@ -58,17 +58,23 @@ class ParamComments
58
58
  def initialize
59
59
  @workflow = ParamWorkflow.new(self)
60
60
 
61
+ reset
62
+ end
63
+
64
+ def reset
61
65
  @current_param = nil
62
66
  @current_option = nil
63
67
  @in_option = false
64
68
  @params_have_started = false
65
69
  @params = []
70
+ @workflow.restore!(:start)
66
71
  end
67
72
 
68
73
  # Walk through every comment and transition the workflow fsm accordingly
69
74
  #
70
75
  # @param comments A list of Comment tokens appearing before the class/defined type header
71
76
  def process(comments) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
77
+ reset
72
78
  @current_comment = PuppetLint::Lexer::Token.new(:COMMENT, '', 1, 1)
73
79
  comments.each do |comment|
74
80
  @current_comment = comment
@@ -121,6 +121,38 @@ describe 'param_comment' do
121
121
  end
122
122
  end
123
123
 
124
+ context 'valid code with multiple classes' do
125
+ let(:code) do
126
+ <<~CODE
127
+ # @summary
128
+ # some class
129
+ #
130
+ # @param mandatory
131
+ # A mandatory parameter
132
+ # with two lines
133
+ class my_class (
134
+ String $mandatory,
135
+ ) {}
136
+
137
+ # @summary
138
+ # some other class
139
+ #
140
+ # @see something
141
+ #
142
+ # @param mandatory
143
+ # A mandatory parameter
144
+ # with two lines
145
+ class my_other_class (
146
+ String $mandatory,
147
+ ) {}
148
+ CODE
149
+ end
150
+
151
+ it 'should not detect any problems' do
152
+ expect(problems).to have(0).problems
153
+ end
154
+ end
155
+
124
156
  context 'code with missing parameter comment' do
125
157
  let(:code) do
126
158
  <<~CODE
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Ploeger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: finite_machine