puppet-lint 4.2.1 → 4.2.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: b8fbf6d28ee384ac72918e39f7a578ccbca81041749e612b9d9ead33a72f7e57
4
- data.tar.gz: 358cdd9a1c4c1c71986b868897855cd6410a538fdff6f8f625fd60007fe062e2
3
+ metadata.gz: 0bbb51ba5c4cc604cd5eb02b2d51791f6df279db955fcd9e77747f79b6890cff
4
+ data.tar.gz: 0e187bb2ab101f20669c387ca3297513ff781edf20d2708e2271ba2778f8df4e
5
5
  SHA512:
6
- metadata.gz: 0073f5e753d913b7d3fc324646bd04fb46eac444ffe6111422f3b2fddbc7008737d4774ce29bfe7b34e946bbcd3301d0d66836ab04ecc88e4f21198eaa4c192e
7
- data.tar.gz: 67f83fcafd14cc225c43f64ddb8326f88a37225700058e83bf2d22fc0a5915bb1096b6e46557c7a88c3e0210bd36ed171136eacef0722e1bb2aa20935efa3b8f
6
+ metadata.gz: 221dc05dc214701d1ffc688ec01fc2c6aa9c3adddc699c55e62894124c66b08a222f864f285bc1e8a65c4466b90967778e02f4f2f7ab805874057ce02db52b72
7
+ data.tar.gz: ba771036c9326dbd2e6831c4fc1ec17f7e81f7f4a41967c801ea78e3d74944dc61f51bda246428b62bedfa58891561bff078a7386d64cd61b6f3b78c5bfa6a66
@@ -1,24 +1,30 @@
1
1
  require 'singleton'
2
2
  require 'set'
3
3
 
4
- # Public: A singleton class storing all the information about the manifest
5
- # being analysed.
4
+ # A singleton class storing all the information about the manifest being
5
+ # analysed.
6
+ #
7
+ # @api public
6
8
  class PuppetLint::Data
7
9
  include Singleton
8
10
 
9
11
  class << self
10
- # Internal: Get/Set the full expanded path to the manifest file being
11
- # checked.
12
+ # Get/Set the full expanded path to the manifest file being checked.
13
+ #
14
+ # @api private
12
15
  attr_reader :path, :fullpath, :filename
13
16
 
14
- # Internal: Get/Set the raw manifest data, split by \n.
17
+ # Get/Set the raw manifest data, split by \n.
18
+ #
19
+ # @api private
15
20
  attr_accessor :manifest_lines
16
21
 
17
- # Internal: Store the tokenised manifest.
22
+ # Store the tokenised manifest.
18
23
  #
19
- # tokens - The Array of PuppetLint::Lexer::Token objects to store.
24
+ # @param [Array[PuppetLint::Lexer::Token]] tokens The Array of PuppetLint::Lexer::Token objects to store.
25
+ # @return [nil]
20
26
  #
21
- # Returns nothing.
27
+ # @api private
22
28
  def tokens=(tokens)
23
29
  @tokens = tokens
24
30
  @title_tokens = nil
@@ -32,14 +38,17 @@ class PuppetLint::Data
32
38
  @defaults_indexes = nil
33
39
  end
34
40
 
41
+ # @api private
35
42
  def ruby1?
36
43
  @ruby1 = RbConfig::CONFIG['MAJOR'] == '1' if @ruby1.nil?
37
44
  @ruby1
38
45
  end
39
46
 
40
- # Public: Get the tokenised manifest.
47
+ # Get the tokenised manifest.
48
+ #
49
+ # @return [Array[PuppetLint::Lexer::Token]]
41
50
  #
42
- # Returns an Array of PuppetLint::Lexer::Token objects.
51
+ # @api public
43
52
  def tokens
44
53
  calling_method = if ruby1?
45
54
  begin
@@ -62,7 +71,12 @@ class PuppetLint::Data
62
71
  end
63
72
  end
64
73
 
65
- # Public: Add new token.
74
+ # Add new token.
75
+ #
76
+ # @param [Integer] index
77
+ # @param [PuppetLint::Lexer::Token] token
78
+ #
79
+ # @api public
66
80
  def insert(index, token)
67
81
  current_token = tokens[index - 1]
68
82
  token.next_token = current_token.next_token
@@ -97,7 +111,11 @@ class PuppetLint::Data
97
111
  tokens.insert(index, token)
98
112
  end
99
113
 
100
- # Public: Removes a token
114
+ # Remove a token
115
+ #
116
+ # @param [PuppetLint::Lexer::Token] token
117
+ #
118
+ # @api public
101
119
  def delete(token)
102
120
  token.next_token.prev_token = token.prev_token unless token.next_token.nil?
103
121
  token.prev_token.next_token = token.next_token unless token.prev_token.nil?
@@ -109,12 +127,13 @@ class PuppetLint::Data
109
127
  tokens.delete(token)
110
128
  end
111
129
 
112
- # Internal: Store the path to the manifest file and populate fullpath and
113
- # filename.
130
+ # Store the path to the manifest file and populate fullpath and filename.
114
131
  #
115
- # val - The path to the file as a String.
132
+ # @param [String] val The path to the file
116
133
  #
117
- # Returns nothing.
134
+ # @return [nil]
135
+ #
136
+ # @api private
118
137
  def path=(val)
119
138
  @path = val
120
139
  if val.nil?
@@ -126,9 +145,11 @@ class PuppetLint::Data
126
145
  end
127
146
  end
128
147
 
129
- # Internal: Retrieve a list of tokens that represent resource titles
148
+ # Retrieve a list of tokens that represent resource titles
149
+ #
150
+ # @return [Array[PuppetLint::Lexer::Token]]
130
151
  #
131
- # Returns an Array of PuppetLint::Lexer::Token objects.
152
+ # @api private
132
153
  def title_tokens
133
154
  @title_tokens ||= begin
134
155
  result = []
@@ -153,10 +174,11 @@ class PuppetLint::Data
153
174
  end
154
175
  end
155
176
 
156
- # Internal: Determine if the given token contains a CLASSREF in
157
- # the token chain..
177
+ # Determine if the given token contains a CLASSREF in the token chain..
158
178
  #
159
- # Returns a Boolean.
179
+ # @param [PuppetLint::Lexer::Token] token
180
+ #
181
+ # @api private
160
182
  def classref?(token)
161
183
  current_token = token
162
184
  while (current_token = current_token.prev_code_token)
@@ -165,15 +187,15 @@ class PuppetLint::Data
165
187
  end
166
188
  end
167
189
 
168
- # Internal: Calculate the positions of all resource declarations within the
190
+ # Calculate the positions of all resource declarations within the
169
191
  # tokenised manifest. These positions only point to the content of the
170
192
  # resource declarations, they do not include resource types or titles.
171
193
  #
172
- # Returns an Array of Hashes, each containing:
173
- # :start - An Integer position in the `tokens` Array pointing to the
174
- # first Token of a resource declaration.
175
- # :end - An Integer position in the `tokens` Array pointing to the last
176
- # Token of a resource declaration.
194
+ # @return [Array[Hash[Symbol, Integer]]] each hash contains :start and
195
+ # :end pointing to the first and last {PuppetLint::Lexer::Token} of a
196
+ # resource declaration
197
+ #
198
+ # @api private
177
199
  def resource_indexes
178
200
  @resource_indexes ||= begin
179
201
  marker = 0
@@ -204,12 +226,15 @@ class PuppetLint::Data
204
226
  end
205
227
  end
206
228
 
207
- # Internal: Find the Token representing the type of a resource definition.
229
+ # Find the Token representing the type of a resource definition.
230
+ #
231
+ # @param [Integer] index
232
+ # The Integer pointing to the start of the resource in the `tokens`
233
+ # array.
208
234
  #
209
- # index - The Integer pointing to the start of the resource in the `tokens`
210
- # array.
235
+ # @return [PuppetLint::Lexer::Token]
211
236
  #
212
- # Returns a Token object.
237
+ # @api private
213
238
  def find_resource_type_token(index)
214
239
  lbrace_idx = tokens[0..index].rindex do |token|
215
240
  token.type == :LBRACE && token.prev_code_token.type != :QMARK
@@ -220,13 +245,15 @@ class PuppetLint::Data
220
245
  tokens[lbrace_idx].prev_code_token
221
246
  end
222
247
 
223
- # Internal: Find all the Token objects representing the parameter names in
248
+ # Find all the Token objects representing the parameter names in
224
249
  # a resource definition.
225
250
  #
226
- # resource_tokens - An Array of Token objects that comprise the resource
227
- # definition.
251
+ # @param [Array[PuppetLint::Lexer::Token]] resource_tokens
252
+ # An Array of Token objects that comprise the resource definition.
228
253
  #
229
- # Returns an Array of Token objects.
254
+ # @return [Array[PuppetLint::Lexer::Token]]
255
+ #
256
+ # @api private
230
257
  def find_resource_param_tokens(resource_tokens)
231
258
  param_tokens = []
232
259
 
@@ -243,8 +270,8 @@ class PuppetLint::Data
243
270
  param_tokens
244
271
  end
245
272
 
246
- # Internal: Calculate the positions of all class definitions within the
247
- # `tokens` Array.
273
+ # Calculate the positions of all class definitions within the `tokens`
274
+ # Array.
248
275
  #
249
276
  # Returns an Array of Hashes, each containing:
250
277
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -253,12 +280,14 @@ class PuppetLint::Data
253
280
  # Token of a class definition.
254
281
  # :tokens - An Array consisting of all the Token objects that make up the
255
282
  # class definition.
283
+ #
284
+ # @api private
256
285
  def class_indexes
257
286
  @class_indexes ||= definition_indexes(:CLASS)
258
287
  end
259
288
 
260
- # Internal: Calculate the positions of all defined type definitions within
261
- # the `tokens` Array.
289
+ # Calculate the positions of all defined type definitions within the
290
+ # `tokens` Array.
262
291
  #
263
292
  # Returns an Array of Hashes, each containing:
264
293
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -267,12 +296,14 @@ class PuppetLint::Data
267
296
  # Token of a defined type definition.
268
297
  # :tokens - An Array consisting of all the Token objects that make up the
269
298
  # defined type.
299
+ #
300
+ # @api private
270
301
  def defined_type_indexes
271
302
  @defined_type_indexes ||= definition_indexes(:DEFINE)
272
303
  end
273
304
 
274
- # Internal: Calculate the positions of all node definitions within the
275
- # `tokens` Array.
305
+ # Calculate the positions of all node definitions within the `tokens`
306
+ # Array.
276
307
  #
277
308
  # Returns an Array of Hashes, each containing:
278
309
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -281,12 +312,14 @@ class PuppetLint::Data
281
312
  # Token of a defined type definition.
282
313
  # :tokens - An Array consisting of all the Token objects that make up the
283
314
  # defined type.
315
+ #
316
+ # @api private
284
317
  def node_indexes
285
318
  @node_indexes ||= definition_indexes(:NODE)
286
319
  end
287
320
 
288
- # Internal: Calculate the positions of all the specified defintion types
289
- # within the `tokens` Array.
321
+ # Calculate the positions of all the specified defintion types within the
322
+ # `tokens` Array.
290
323
  #
291
324
  # Returns an Array of Hashes, each containing:
292
325
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -295,6 +328,8 @@ class PuppetLint::Data
295
328
  # Token of a definition.
296
329
  # :tokens - An Array consisting of all the Token objects that make up the
297
330
  # definition.
331
+ #
332
+ # @api private
298
333
  def definition_indexes(type)
299
334
  result = []
300
335
  tokens.each_with_index do |token, i|
@@ -336,8 +371,7 @@ class PuppetLint::Data
336
371
  result
337
372
  end
338
373
 
339
- # Internal: Calculate the positions of all function calls within
340
- # `tokens` Array.
374
+ # Calculate the positions of all function calls within `tokens` Array.
341
375
  #
342
376
  # Returns an Array of Hashes, each containing:
343
377
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -346,6 +380,8 @@ class PuppetLint::Data
346
380
  # Token of a function call
347
381
  # :tokens - An Array consisting of all the Token objects that make up the
348
382
  # function call.
383
+ #
384
+ # @api private
349
385
  def function_indexes
350
386
  @function_indexes ||= begin
351
387
  functions = []
@@ -385,8 +421,7 @@ class PuppetLint::Data
385
421
  end
386
422
  end
387
423
 
388
- # Internal: Calculate the positions of all array values within
389
- # `tokens` Array.
424
+ # Calculate the positions of all array values within `tokens` Array.
390
425
  #
391
426
  # Returns an Array of Hashes, each containing:
392
427
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -395,6 +430,8 @@ class PuppetLint::Data
395
430
  # Token of an array value
396
431
  # :tokens - An Array consisting of all the Token objects that make up the
397
432
  # array value.
433
+ #
434
+ # @api private
398
435
  def array_indexes
399
436
  @array_indexes ||= begin
400
437
  arrays = []
@@ -421,8 +458,7 @@ class PuppetLint::Data
421
458
  end
422
459
  end
423
460
 
424
- # Internal: Calculate the positions of all hash values within
425
- # `tokens` Array.
461
+ # Calculate the positions of all hash values within `tokens` Array.
426
462
  #
427
463
  # Returns an Array of Hashes, each containing:
428
464
  # :start - An Integer position in the `tokens` Array pointing to the
@@ -431,6 +467,8 @@ class PuppetLint::Data
431
467
  # Token of an hash value
432
468
  # :tokens - An Array consisting of all the Token objects that make up the
433
469
  # hash value.
470
+ #
471
+ # @api private
434
472
  def hash_indexes
435
473
  @hash_indexes ||= begin
436
474
  hashes = []
@@ -459,7 +497,7 @@ class PuppetLint::Data
459
497
  end
460
498
  end
461
499
 
462
- # Internal: Calculate the positions of all defaults declarations within
500
+ # Calculate the positions of all defaults declarations within
463
501
  # `tokens` Array.
464
502
  #
465
503
  # Returns an Array of Hashes, each containing:
@@ -469,6 +507,8 @@ class PuppetLint::Data
469
507
  # Token of the defaults declaration
470
508
  # :tokens - An Array consisting of all the Token objects that make up the
471
509
  # defaults declaration.
510
+ #
511
+ # @api private
472
512
  def defaults_indexes
473
513
  @defaults_indexes ||= begin
474
514
  defaults = []
@@ -493,14 +533,17 @@ class PuppetLint::Data
493
533
  end
494
534
  end
495
535
 
496
- # Internal: Finds all the tokens that make up the defined type or class
536
+ # Finds all the tokens that make up the defined type or class
497
537
  # definition parameters.
498
538
  #
499
- # these_tokens - An Array of PuppetLint::Lexer::Token objects that make up
500
- # the defined type or class definition.
539
+ # @param [Array[PuppetLint::Lexer::Token]] these_tokens
540
+ # An Array of PuppetLint::Lexer::Token objects that make up the defined
541
+ # type or class definition.
501
542
  #
502
- # Returns an Array of PuppetLint::Lexer::Token objects or nil if it takes
503
- # no parameters.
543
+ # @return [Array[PuppetLint::Lexer::Token], nil] objects or nil if it takes
544
+ # no parameters.
545
+ #
546
+ # @api private
504
547
  def param_tokens(these_tokens)
505
548
  depth = 0
506
549
  lparen_idx = nil
@@ -529,28 +572,34 @@ class PuppetLint::Data
529
572
  end
530
573
  end
531
574
 
532
- # Internal: Retrieves a list of token types that are considered to be
575
+ # Retrieves a list of token types that are considered to be
533
576
  # formatting tokens (whitespace, newlines, etc).
534
577
  #
535
- # Returns an Array of Symbols.
578
+ # @return [Array[Symbol]]
579
+ #
580
+ # @api private
536
581
  def formatting_tokens
537
582
  @formatting_tokens ||= PuppetLint::Lexer::FORMATTING_TOKENS
538
583
  end
539
584
 
540
- # Internal: Retrieves a Hash of Sets. Each key is a check name Symbol and
585
+ # Retrieves a Hash of Sets. Each key is a check name Symbol and
541
586
  # the Set of Integers returned lists all the lines that the check results
542
587
  # should be ignored on.
543
588
  #
544
- # Returns a Hash of Sets of Integers.
589
+ # @return [Hash[Symbol, Set[Integer]]]
590
+ #
591
+ # @api private
545
592
  def ignore_overrides
546
593
  @ignore_overrides ||= {}
547
594
  end
548
595
 
549
- # Internal: Parses all COMMENT, MLCOMMENT and SLASH_COMMENT tokens looking
596
+ # Parses all COMMENT, MLCOMMENT and SLASH_COMMENT tokens looking
550
597
  # for control comments (comments that enable or disable checks). Builds the
551
598
  # contents of the `ignore_overrides` hash.
552
599
  #
553
- # Returns nothing.
600
+ # @return [nil]
601
+ #
602
+ # @api private
554
603
  def parse_control_comments
555
604
  @ignore_overrides.each_key { |check| @ignore_overrides[check].clear }
556
605
 
@@ -9,7 +9,7 @@ class PuppetLint::LineLengthCheck
9
9
  # @param content [String] The content of the current line.
10
10
  # @param character_count [Integer] The maximum number of characters allowed
11
11
  #
12
- # @return problem [Array] An array containing a description of the problem.
12
+ # @return [Array] An array containing a description of the problem.
13
13
  # Can be passed directly to notify..
14
14
  def self.check(line_number, content, character_count)
15
15
  return if content.include? '://'
@@ -1,3 +1,3 @@
1
1
  class PuppetLint
2
- VERSION = '4.2.1'.freeze
2
+ VERSION = '4.2.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
@@ -10,12 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-10-09 00:00:00.000000000 Z
13
+ date: 2023-11-22 00:00:00.000000000 Z
14
14
  dependencies: []
15
- description: |2
16
- Checks your Puppet manifests against the Puppetlabs style guide and alerts you to any discrepancies.
17
- Note: Support for this gem has been moved under a new namespace and as such any future updates from
18
- the Puppet team will be released as `puppetlabs-puppet-lint`.
15
+ description: " Checks your Puppet manifests against the Puppetlabs style guide
16
+ and alerts you to any discrepancies.\n"
19
17
  email:
20
18
  - tim@sharpe.id.au
21
19
  - modules-team@puppet.com