puppet-lint 3.4.0 → 4.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/puppet-lint/bin.rb +7 -11
  3. data/lib/puppet-lint/checkplugin.rb +4 -8
  4. data/lib/puppet-lint/checks.rb +7 -9
  5. data/lib/puppet-lint/configuration.rb +2 -2
  6. data/lib/puppet-lint/data.rb +35 -39
  7. data/lib/puppet-lint/lexer/string_slurper.rb +2 -3
  8. data/lib/puppet-lint/lexer/token.rb +6 -5
  9. data/lib/puppet-lint/lexer.rb +35 -38
  10. data/lib/puppet-lint/monkeypatches.rb +4 -4
  11. data/lib/puppet-lint/optparser.rb +1 -1
  12. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +1 -0
  13. data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +2 -4
  14. data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +2 -2
  15. data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +1 -1
  16. data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +5 -5
  17. data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +8 -9
  18. data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +32 -34
  19. data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +2 -2
  20. data/lib/puppet-lint/plugins/check_documentation/documentation.rb +7 -6
  21. data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +1 -1
  22. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +3 -5
  23. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +2 -2
  24. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +6 -6
  25. data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +4 -4
  26. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +4 -4
  27. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +4 -5
  28. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +4 -4
  29. data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +2 -2
  30. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +8 -7
  31. data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +3 -3
  32. data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +2 -2
  33. data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +1 -0
  34. data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +2 -1
  35. data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +9 -9
  36. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +2 -2
  37. data/lib/puppet-lint/plugins/check_whitespace/line_length.rb +6 -6
  38. data/lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb +106 -105
  39. data/lib/puppet-lint/plugins/top_scope_facts/top_scope_facts.rb +3 -2
  40. data/lib/puppet-lint/plugins.rb +3 -4
  41. data/lib/puppet-lint/report/codeclimate.rb +3 -2
  42. data/lib/puppet-lint/report/github.rb +1 -0
  43. data/lib/puppet-lint/tasks/puppet-lint.rb +7 -26
  44. data/lib/puppet-lint/tasks/release_test.rb +4 -4
  45. data/lib/puppet-lint/version.rb +1 -1
  46. data/lib/puppet-lint.rb +5 -3
  47. data/rubocop_baseline.yml +3 -440
  48. data/spec/spec_helper.rb +3 -2
  49. data/spec/spec_helper_acceptance_local.rb +1 -1
  50. data/spec/unit/puppet-lint/bin_spec.rb +12 -2
  51. data/spec/unit/puppet-lint/configuration_spec.rb +14 -14
  52. data/spec/unit/puppet-lint/lexer/string_slurper_spec.rb +3 -5
  53. data/spec/unit/puppet-lint/lexer_spec.rb +10 -11
  54. data/spec/unit/puppet-lint/plugins/check_classes/parameter_order_spec.rb +2 -2
  55. data/spec/unit/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +5 -5
  56. data/spec/unit/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +1 -1
  57. data/spec/unit/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +1 -1
  58. data/spec/unit/puppet-lint/plugins/check_whitespace/140chars_spec.rb +0 -2
  59. data/spec/unit/puppet-lint/plugins/check_whitespace/80chars_spec.rb +1 -3
  60. data/spec/unit/puppet-lint/plugins/legacy_facts/legacy_facts_spec.rb +16 -0
  61. data/spec/unit/puppet-lint/plugins/top_scope_facts/top_scope_facts_spec.rb +1 -0
  62. metadata +5 -5
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe PuppetLint::Lexer do
@@ -13,7 +11,7 @@ describe PuppetLint::Lexer do
13
11
  end
14
12
  end
15
13
 
16
- context '#new_token' do
14
+ describe '#new_token' do
17
15
  it 'calculates the line number for an empty string' do
18
16
  token = lexer.new_token(:TEST, 'test')
19
17
  expect(token.line).to eq(1)
@@ -55,19 +53,19 @@ describe PuppetLint::Lexer do
55
53
  end
56
54
 
57
55
  it 'calculates the column number for a multi line string' do
58
- lexer.instance_variable_set('@line_no', 4)
59
- lexer.instance_variable_set('@column', 5)
56
+ lexer.instance_variable_set(:@line_no, 4)
57
+ lexer.instance_variable_set(:@column, 5)
60
58
  lexer.new_token(:SSTRING, "test\ntest")
61
59
  token = lexer.new_token(:TEST, 'test')
62
60
  expect(token.column).to eq(6)
63
61
  end
64
62
  end
65
63
 
66
- context '#process_string_segments' do
67
- subject(:tokens) { lexer.tokens }
68
-
64
+ describe '#process_string_segments' do
69
65
  subject(:manifest) { lexer.tokens.map(&:to_manifest).join }
70
66
 
67
+ let(:tokens) { lexer.tokens }
68
+
71
69
  before(:each) do
72
70
  lexer.process_string_segments(segments)
73
71
  end
@@ -1291,7 +1289,7 @@ END
1291
1289
  it 'does not enclose variable with a chained function call' do
1292
1290
  manifest = '"This is ${a.test}"'
1293
1291
  tokens = lexer.tokenise(manifest)
1294
- expect(tokens.map(&:to_manifest).join('')).to eq(manifest)
1292
+ expect(tokens.map(&:to_manifest).join).to eq(manifest)
1295
1293
  end
1296
1294
  end
1297
1295
 
@@ -1382,6 +1380,7 @@ END
1382
1380
  expect(token.type).to eq(:TYPE)
1383
1381
  expect(token.value).to eq('Callable')
1384
1382
  end
1383
+
1385
1384
  it 'matches Sensitive' do
1386
1385
  token = lexer.tokenise('Sensitive').first
1387
1386
  expect(token.type).to eq(:TYPE)
@@ -1689,7 +1688,7 @@ END
1689
1688
  END
1690
1689
 
1691
1690
  tokens = lexer.tokenise(manifest)
1692
- expect(tokens.map(&:to_manifest).join('')).to eq(manifest)
1691
+ expect(tokens.map(&:to_manifest).join).to eq(manifest)
1693
1692
 
1694
1693
  expect(tokens[0].type).to eq(:VARIABLE)
1695
1694
  expect(tokens[0].value).to eq('str')
@@ -1756,7 +1755,7 @@ END
1756
1755
  expect(tokens[7].raw).to eq('$myvar')
1757
1756
  expect(tokens[7].to_manifest).to eq('$myvar')
1758
1757
 
1759
- expect(tokens.map(&:to_manifest).join('')).to eq(manifest)
1758
+ expect(tokens.map(&:to_manifest).join).to eq(manifest)
1760
1759
  end
1761
1760
  end
1762
1761
 
@@ -27,7 +27,7 @@ describe 'parameter_order' do
27
27
  expect(problems).to have(1).problem
28
28
  end
29
29
 
30
- col = (type == 'class' ? 23 : 24)
30
+ col = ((type == 'class') ? 23 : 24)
31
31
  it 'creates a warning' do
32
32
  expect(problems).to contain_warning(msg).on_line(1).in_column(col)
33
33
  end
@@ -58,7 +58,7 @@ describe 'parameter_order' do
58
58
  expect(problems).to have(1).problem
59
59
  end
60
60
 
61
- col = (type == 'class' ? 35 : 36)
61
+ col = ((type == 'class') ? 35 : 36)
62
62
  it 'creates a warning' do
63
63
  expect(problems).to contain_warning(msg).on_line(1).in_column(col)
64
64
  end
@@ -87,15 +87,15 @@ describe 'case_without_default' do
87
87
  let(:code) do
88
88
  <<-END
89
89
  $mem = inline_template('<%
90
- mem,unit = scope.lookupvar(\'::memorysize\').split
90
+ mem,unit = scope.lookupvar('::memorysize').split
91
91
  mem = mem.to_f
92
92
  # Normalize mem to bytes
93
93
  case unit
94
94
  when nil: mem *= (1<<0)
95
- when \'kB\': mem *= (1<<10)
96
- when \'MB\': mem *= (1<<20)
97
- when \'GB\': mem *= (1<<30)
98
- when \'TB\': mem *= (1<<40)
95
+ when 'kB': mem *= (1<<10)
96
+ when 'MB': mem *= (1<<20)
97
+ when 'GB': mem *= (1<<30)
98
+ when 'TB': mem *= (1<<40)
99
99
  end
100
100
  %><%= mem.to_i %>')
101
101
  END
@@ -98,7 +98,7 @@ describe 'double_quoted_strings' do
98
98
  <<-END
99
99
  $string1 = "this string contains \n newline"
100
100
  $string2 = "this string contains \t tab"
101
- $string3 = "this string contains \${escaped} var"
101
+ $string3 = "this string contains ${escaped} var"
102
102
  $string4 = "this string contains \\"escaped \\" double quotes"
103
103
  $string5 = "this string contains \\'escaped \\' single quotes"
104
104
  $string6 = "this string contains \r carriage return"
@@ -45,7 +45,7 @@ describe 'only_variable_string' do
45
45
  <<-END
46
46
  $bar = 'key'
47
47
  $foo = {
48
- \"$bar\" => 1,
48
+ "$bar" => 1,
49
49
  }
50
50
  END
51
51
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe '140chars' do
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe '80chars' do
6
4
  before(:each) do
7
- PuppetLint.configuration.send('enable_80chars')
5
+ PuppetLint.configuration.send(:enable_80chars)
8
6
  end
9
7
 
10
8
  let(:msg) { 'line has more than 80 characters' }
@@ -250,6 +250,7 @@ describe 'legacy_facts' do
250
250
  it 'onlies detect a single problem' do
251
251
  expect(problems).to have(1).problem
252
252
  end
253
+
253
254
  it 'uses the facts hash' do
254
255
  expect(manifest).to eq("$facts['disks']['sda']['model']")
255
256
  end
@@ -261,6 +262,7 @@ describe 'legacy_facts' do
261
262
  it 'onlies detect a single problem' do
262
263
  expect(problems).to have(1).problem
263
264
  end
265
+
264
266
  it 'uses the facts hash' do
265
267
  expect(manifest).to eq("$facts['networking']['interfaces']['em2']['ip6']")
266
268
  end
@@ -272,6 +274,7 @@ describe 'legacy_facts' do
272
274
  it 'onlies detect a single problem' do
273
275
  expect(problems).to have(1).problem
274
276
  end
277
+
275
278
  it 'uses the facts hash' do
276
279
  expect(manifest).to eq("$facts['solaris_zones']['zones']['foobar']['uuid']")
277
280
  end
@@ -283,6 +286,7 @@ describe 'legacy_facts' do
283
286
  it 'onlies detect a single problem' do
284
287
  expect(problems).to have(1).problem
285
288
  end
289
+
286
290
  it 'uses the facts hash' do
287
291
  expect(manifest).to eq("$facts['processors']['models'][314]")
288
292
  end
@@ -294,6 +298,7 @@ describe 'legacy_facts' do
294
298
  it 'onlies detect a single problem' do
295
299
  expect(problems).to have(1).problem
296
300
  end
301
+
297
302
  it 'uses the facts hash' do
298
303
  expect(manifest).to eq("$facts['system_profiler']['l3_cache']")
299
304
  end
@@ -305,6 +310,7 @@ describe 'legacy_facts' do
305
310
  it 'onlies detect a single problem' do
306
311
  expect(problems).to have(1).problem
307
312
  end
313
+
308
314
  it 'uses the facts hash' do
309
315
  expect(manifest).to eq("$facts['ssh']['rsa']['key']")
310
316
  end
@@ -333,6 +339,7 @@ describe 'legacy_facts' do
333
339
  expect(manifest).to eq("\"$facts['os']['family']\"")
334
340
  end
335
341
  end
342
+
336
343
  context 'fact variable using legacy variable in double quotes "$::gid"' do
337
344
  let(:code) { '"$::gid"' }
338
345
 
@@ -344,6 +351,7 @@ describe 'legacy_facts' do
344
351
  expect(manifest).to eq("\"$facts['identity']['group']\"")
345
352
  end
346
353
  end
354
+
347
355
  context 'fact variable using legacy variable in double quotes "$::id"' do
348
356
  let(:code) { '"$::id"' }
349
357
 
@@ -355,6 +363,7 @@ describe 'legacy_facts' do
355
363
  expect(manifest).to eq("\"$facts['identity']['user']\"")
356
364
  end
357
365
  end
366
+
358
367
  context 'fact variable using legacy variable in double quotes "$::lsbdistcodename"' do
359
368
  let(:code) { '"$::lsbdistcodename"' }
360
369
 
@@ -366,6 +375,7 @@ describe 'legacy_facts' do
366
375
  expect(manifest).to eq("\"$facts['os']['distro']['codename']\"")
367
376
  end
368
377
  end
378
+
369
379
  context 'fact variable using legacy variable in double quotes "$::lsbdistdescription"' do
370
380
  let(:code) { '"$::lsbdistdescription"' }
371
381
 
@@ -377,6 +387,7 @@ describe 'legacy_facts' do
377
387
  expect(manifest).to eq("\"$facts['os']['distro']['description']\"")
378
388
  end
379
389
  end
390
+
380
391
  context 'fact variable using legacy variable in double quotes "$::lsbdistid"' do
381
392
  let(:code) { '"$::lsbdistid"' }
382
393
 
@@ -388,6 +399,7 @@ describe 'legacy_facts' do
388
399
  expect(manifest).to eq("\"$facts['os']['distro']['id']\"")
389
400
  end
390
401
  end
402
+
391
403
  context 'fact variable using legacy variable in double quotes "$::lsbdistrelease"' do
392
404
  let(:code) { '"$::lsbdistrelease"' }
393
405
 
@@ -399,6 +411,7 @@ describe 'legacy_facts' do
399
411
  expect(manifest).to eq("\"$facts['os']['distro']['release']['full']\"")
400
412
  end
401
413
  end
414
+
402
415
  context 'fact variable using legacy variable in double quotes "$::lsbmajdistrelease"' do
403
416
  let(:code) { '"$::lsbmajdistrelease"' }
404
417
 
@@ -410,6 +423,7 @@ describe 'legacy_facts' do
410
423
  expect(manifest).to eq("\"$facts['os']['distro']['release']['major']\"")
411
424
  end
412
425
  end
426
+
413
427
  context 'fact variable using legacy variable in double quotes "$::lsbminordistrelease"' do
414
428
  let(:code) { '"$::lsbminordistrelease"' }
415
429
 
@@ -421,6 +435,7 @@ describe 'legacy_facts' do
421
435
  expect(manifest).to eq("\"$facts['os']['distro']['release']['minor']\"")
422
436
  end
423
437
  end
438
+
424
439
  context 'fact variable using legacy variable in double quotes "$::lsbrelease"' do
425
440
  let(:code) { '"$::lsbrelease"' }
426
441
 
@@ -432,6 +447,7 @@ describe 'legacy_facts' do
432
447
  expect(manifest).to eq("\"$facts['os']['distro']['release']['specification']\"")
433
448
  end
434
449
  end
450
+
435
451
  context "fact variable using facts hash in double quotes \"$facts['lsbrelease']\"" do
436
452
  let(:code) { "\"${facts['lsbrelease']}\"" }
437
453
 
@@ -11,6 +11,7 @@ describe 'top_scope_facts' do
11
11
  expect(problems).to have(0).problem
12
12
  end
13
13
  end
14
+
14
15
  context 'non-fact variable with two colons' do
15
16
  let(:code) { '$foo::bar' }
16
17
 
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: 3.4.0
4
+ version: 4.0.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-04-05 00:00:00.000000000 Z
13
+ date: 2023-04-13 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: " Checks your Puppet manifests against the Puppetlabs style guide
16
16
  and alerts you to any discrepancies.\n"
@@ -162,12 +162,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- version: '2.5'
165
+ version: '2.7'
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - ">="
168
+ - - ">"
169
169
  - !ruby/object:Gem::Version
170
- version: '0'
170
+ version: 1.3.1
171
171
  requirements: []
172
172
  rubygems_version: 3.1.6
173
173
  signing_key: