puppet-lint 4.2.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -4
  3. data/lib/puppet-lint/lexer.rb +2 -2
  4. data/lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb +2 -2
  5. data/lib/puppet-lint/plugins/top_scope_facts/top_scope_facts.rb +4 -4
  6. data/lib/puppet-lint/version.rb +1 -1
  7. data/rubocop_baseline.yml +7 -0
  8. data/spec/spec_helper.rb +0 -1
  9. data/spec/unit/puppet-lint/checks_spec.rb +7 -2
  10. data/spec/unit/puppet-lint/ignore_overrides_spec.rb +6 -6
  11. data/spec/unit/puppet-lint/lexer_spec.rb +702 -699
  12. data/spec/unit/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb +5 -5
  13. data/spec/unit/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +8 -8
  14. data/spec/unit/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +2 -2
  15. data/spec/unit/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +2 -1
  16. data/spec/unit/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +3 -3
  17. data/spec/unit/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +3 -3
  18. data/spec/unit/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +3 -3
  19. data/spec/unit/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +5 -5
  20. data/spec/unit/puppet-lint/plugins/check_classes/parameter_order_spec.rb +14 -14
  21. data/spec/unit/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +2 -2
  22. data/spec/unit/puppet-lint/plugins/check_classes/variable_scope_spec.rb +21 -21
  23. data/spec/unit/puppet-lint/plugins/check_comments/slash_comments_spec.rb +2 -2
  24. data/spec/unit/puppet-lint/plugins/check_comments/star_comments_spec.rb +4 -4
  25. data/spec/unit/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +6 -6
  26. data/spec/unit/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +2 -2
  27. data/spec/unit/puppet-lint/plugins/check_documentation/documentation_spec.rb +5 -5
  28. data/spec/unit/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +11 -11
  29. data/spec/unit/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +6 -6
  30. data/spec/unit/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +12 -12
  31. data/spec/unit/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +4 -4
  32. data/spec/unit/puppet-lint/plugins/check_resources/file_mode_spec.rb +22 -22
  33. data/spec/unit/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +8 -8
  34. data/spec/unit/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +13 -13
  35. data/spec/unit/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +18 -18
  36. data/spec/unit/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +6 -6
  37. data/spec/unit/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +4 -4
  38. data/spec/unit/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +8 -8
  39. data/spec/unit/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +3 -3
  40. data/spec/unit/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +7 -7
  41. data/spec/unit/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +2 -2
  42. data/spec/unit/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb +5 -5
  43. data/spec/unit/puppet-lint/plugins/check_whitespace/140chars_spec.rb +4 -4
  44. data/spec/unit/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +1 -1
  45. data/spec/unit/puppet-lint/plugins/check_whitespace/80chars_spec.rb +4 -4
  46. data/spec/unit/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +37 -37
  47. data/spec/unit/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +2 -2
  48. data/spec/unit/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +6 -6
  49. data/spec/unit/puppet-lint/plugins/legacy_facts/legacy_facts_spec.rb +83 -75
  50. data/spec/unit/puppet-lint/plugins/top_scope_facts/top_scope_facts_spec.rb +19 -19
  51. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69069ebb59ecc423674d2918bf4493ae0da816b8d9a6f3da7db8a34cc7e657bf
4
- data.tar.gz: 28cfb8db332d53efcaab17e412a1f965a382a341aa3696c2148116ce18b4570b
3
+ metadata.gz: b8fbf6d28ee384ac72918e39f7a578ccbca81041749e612b9d9ead33a72f7e57
4
+ data.tar.gz: 358cdd9a1c4c1c71986b868897855cd6410a538fdff6f8f625fd60007fe062e2
5
5
  SHA512:
6
- metadata.gz: 3f951b0291881ea53286adf57085a8cc0ef5164028ca2c815b05bd196f4f35f038d10910fb417d03465590ba0af20a835fceaa1037808f5a697d8c1ce0ce3b76
7
- data.tar.gz: 4c6347b7c83ab801cc03994c4422239ebec41ce851179f4362c43b0aa012f61ea362aebc27b0a8da5abd3c42fea1274d10c97092782f24635d95eb9b96612b03
6
+ metadata.gz: 0073f5e753d913b7d3fc324646bd04fb46eac444ffe6111422f3b2fddbc7008737d4774ce29bfe7b34e946bbcd3301d0d66836ab04ecc88e4f21198eaa4c192e
7
+ data.tar.gz: 67f83fcafd14cc225c43f64ddb8326f88a37225700058e83bf2d22fc0a5915bb1096b6e46557c7a88c3e0210bd36ed171136eacef0722e1bb2aa20935efa3b8f
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # Puppet Lint
2
2
 
3
+ [![Code Owners](https://img.shields.io/badge/owners-DevX--team-blue)](https://github.com/puppetlabs/puppet-lint/blob/main/CODEOWNERS)
4
+ ![ci](https://github.com/puppetlabs/puppet-lint/actions/workflows/ci.yml/badge.svg)
5
+ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/puppetlabs/puppet-lint)
6
+
3
7
  Puppet Lint tests Puppet code against the recommended [Puppet language style
4
8
  guide](http://puppet.com/docs/puppet/latest/style_guide.html). Puppet Lint validates only code style; it does not validate syntax. To test syntax, use Puppet's `puppet parser validate` command.
5
9
 
6
10
  ## Compatibility warning
7
11
 
8
- Version 3.0.0 and above will no longer support Puppet 6 environments.
9
-
10
- In cases where Puppet Lint is required in an environment with Puppet 6, we recommend pinning to version 2.5.2.
12
+ This tool is only supported on Puppet 7 & 8 environments. In cases where Puppet Lint is required in an environment with Puppet 6, we recommend pinning to version 2.5.2.
11
13
 
12
14
  ## Installation
13
15
 
@@ -112,7 +114,7 @@ Any flag that can be specified on the command line can also be specified in the
112
114
  --no-hard_tabs-check
113
115
  ```
114
116
 
115
- Or to specify a whitelist of allowed checks, include a line like:
117
+ Or to specify an allowlist of allowed checks, include a line like:
116
118
 
117
119
  ```
118
120
  --only-checks=trailing_whitespace,hard_tabs,duplicate_params,double_quoted_strings,unquoted_file_mode,only_variable_string,variables_not_enclosed,single_quote_string_with_variables,variable_contains_dash,ensure_not_symlink_target,unquoted_resource_title,relative_classname_inclusion,file_mode,resource_reference_without_title_capital,leading_zero,arrow_alignment,variable_is_lowercase,ensure_first_param,resource_reference_without_whitespace,file_ensure,trailing_comma,leading_zero
@@ -293,6 +295,18 @@ If you find a bug in Puppet Lint or its results, please create an issue in the
293
295
  [repo issues tracker](https://github.com/puppetlabs/puppet-lint/issues/). Bonus
294
296
  points will be awarded if you also include a patch that fixes the issue.
295
297
 
298
+ ## Development
299
+
300
+ Acceptance tests for this tool leverage [puppet_litmus](https://github.com/puppetlabs/puppet_litmus).
301
+ To run the acceptance tests follow the instructions [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module).
302
+ You can also find a tutorial and walkthrough of using Litmus and the PDK on [YouTube](https://www.youtube.com/watch?v=FYfR7ZEGHoE).
303
+
304
+ If you run into an issue with this tool or would like to request a feature you can [raise a PR](https://github.com/puppetlabs/puppet-lint/pulls) with your suggested changes. Alternatively, you can [raise a Github issue](https://github.com/puppetlabs/puppet-lint/issues) with a feature request or to report any bugs.
305
+ Every other Tuesday the DevX team holds [office hours](https://puppet.com/community/office-hours) in the [Puppet Community Slack](http://slack.puppet.com/), where you can ask questions about this and any other supported tools.
306
+ This session runs at 15:00 (GMT) for about an hour.
307
+
308
+ If you have problems getting this tool up and running, please [contact Support](http://puppetlabs.com/services/customer-support).
309
+
296
310
  ## Thank you
297
311
 
298
312
  Many thanks to the following people for contributing to puppet-lint
@@ -50,7 +50,7 @@ class PuppetLint::Lexer
50
50
 
51
51
  # Internal: A Hash whose keys are Strings representing reserved keywords in
52
52
  # the Puppet DSL.
53
- # From https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/parser/lexer2.rb#L116-L137
53
+ # From https://github.com/puppetlabs/puppet/blob/main/lib/puppet/pops/parser/lexer2.rb#L116-L137
54
54
  # or thereabouts
55
55
  KEYWORDS = {
56
56
  'case' => true,
@@ -78,7 +78,7 @@ class PuppetLint::Lexer
78
78
 
79
79
  # Internal: A Hash whose keys are Strings representing reserved keywords in
80
80
  # the Puppet DSL when Application Management is enabled
81
- # From https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/parser/lexer2.rb#L142-L159
81
+ # From https://github.com/puppetlabs/puppet/blob/main/lib/puppet/pops/parser/lexer2.rb#L142-L159
82
82
  # or therabouts
83
83
  # Currently unused
84
84
  APP_MANAGEMENT_TOKENS = {
@@ -116,8 +116,8 @@ PuppetLint.new_check(:legacy_facts) do
116
116
  fact_name = ''
117
117
 
118
118
  # This matches legacy facts defined in the fact hash.
119
- if (match = (token.value.match(%r{(::)?facts\['(.*)'\]}) || token.value.match(%r{(::)?facts\[(.*)\]})))
120
- fact_name = match[2]
119
+ if (match = token.value.match(%r{^(?:::)?facts\[(?<quote>'?)(?<value>.+)\k<quote>\]$}))
120
+ fact_name = match[:value]
121
121
 
122
122
  # This matches using legacy facts in a the new structured fact. For
123
123
  # example this would match 'uuid' in $facts['uuid'] so it can be converted
@@ -7,7 +7,7 @@
7
7
  # If you have top scope variables that aren't facts you should configure the
8
8
  # linter to ignore them.
9
9
  #
10
- # You can whitelist top scope variables to ignore via the Rake task.
10
+ # You can allowlist top scope variables to ignore via the Rake task.
11
11
  # You should insert the following line to your Rakefile.
12
12
  # `PuppetLint.configuration.top_scope_variables = ['location', 'role']`
13
13
  #
@@ -17,7 +17,7 @@ TOP_SCOPE_FACTS_VAR_TYPES = Set[:VARIABLE, :UNENC_VARIABLE]
17
17
 
18
18
  PuppetLint.new_check(:top_scope_facts) do
19
19
  def check
20
- whitelist = ['trusted', 'facts', 'architecture', 'augeasversion', 'bios_release_date', 'bios_vendor', 'bios_version',
20
+ allowlist = ['trusted', 'facts', 'architecture', 'augeasversion', 'bios_release_date', 'bios_vendor', 'bios_version',
21
21
  'boardassettag', 'boardmanufacturer', 'boardproductname', 'boardserialnumber', 'chassisassettag', 'chassistype', 'domain',
22
22
  'fqdn', 'gid', 'hardwareisa', 'hardwaremodel', 'hostname', 'id', 'ipaddress', 'ipaddress6', 'lsbdistcodename',
23
23
  'lsbdistdescription', 'lsbdistid', 'lsbdistrelease', 'lsbmajdistrelease', 'lsbminordistrelease', 'lsbrelease',
@@ -28,10 +28,10 @@ PuppetLint.new_check(:top_scope_facts) do
28
28
  'selinux_config_policy', 'selinux_current_mode', 'selinux_enforced', 'selinux_policyversion', 'serialnumber',
29
29
  'swapencrypted', 'swapfree', 'swapsize', 'system32', 'uptime', 'uptime_days', 'uptime_hours', 'uptime_seconds',
30
30
  'uuid', 'xendomains', 'zonename'] + (PuppetLint.configuration.top_scope_variables || [])
31
- whitelist = whitelist.join('|')
31
+ allowlist = allowlist.join('|')
32
32
  tokens.select { |x| TOP_SCOPE_FACTS_VAR_TYPES.include?(x.type) }.each do |token|
33
33
  next unless %r{^::}.match?(token.value)
34
- next if %r{^::(#{whitelist})\[?}.match?(token.value)
34
+ next if %r{^::(#{allowlist})\[?}.match?(token.value)
35
35
  next if %r{^::[a-z0-9_][a-zA-Z0-9_]+::}.match?(token.value)
36
36
 
37
37
  notify :warning, {
@@ -1,3 +1,3 @@
1
1
  class PuppetLint
2
- VERSION = '4.2.0'.freeze
2
+ VERSION = '4.2.1'.freeze
3
3
  end
data/rubocop_baseline.yml CHANGED
@@ -81,3 +81,10 @@ Style/Documentation:
81
81
  - spec/**/*
82
82
  Style/WordArray:
83
83
  EnforcedStyle: brackets
84
+ ####################################################
85
+ # Cops below here due for deprecation
86
+ ####################################################
87
+ # ``Rspec/FilePath`` is going to be deprecated in the next major release of rubocop >=3.0.0: see <https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath>
88
+ # As the new cops are already present, e.g., Rspec/SpecFilePathPathFormat, then disabling this in preparation
89
+ RSpec/FilePath:
90
+ Enabled: false
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,6 @@ end
12
12
 
13
13
  require 'puppet-lint'
14
14
  require 'rspec/its'
15
- require 'rspec/collection_matchers'
16
15
  begin
17
16
  require 'rspec/json_expectations'
18
17
  rescue LoadError, SyntaxError
@@ -31,7 +31,7 @@ describe PuppetLint::Checks do
31
31
  end
32
32
 
33
33
  it 'creates a syntax error problem for the file' do
34
- expect(instance.problems).to have(1).problem
34
+ expect(instance.problems.size).to eq(1)
35
35
  expect(instance.problems.first).to include(
36
36
  kind: :error,
37
37
  check: :syntax,
@@ -53,7 +53,7 @@ describe PuppetLint::Checks do
53
53
  end
54
54
 
55
55
  it 'creates a syntax error problem for the file' do
56
- expect(instance.problems).to have(1).problem
56
+ expect(instance.problems.size).to eq(1)
57
57
  expect(instance.problems.first).to include(
58
58
  kind: :error,
59
59
  check: :syntax,
@@ -148,9 +148,14 @@ describe PuppetLint::Checks do
148
148
 
149
149
  it 'prints out information about the puppet-lint version and ruby environment' do
150
150
  expected_info = [
151
+ 'Whoops! It looks like puppet-lint has encountered an error that it doesn\'t',
152
+ 'know how to handle. Please open an issue at https://github.com/puppetlabs/puppet-lint',
153
+ 'and paste the following output into the issue description.',
154
+ '---',
151
155
  "puppet-lint version: #{PuppetLint::VERSION}",
152
156
  "ruby version: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
153
157
  "platform: #{RUBY_PLATFORM}",
158
+ "file path: #{fileinfo}",
154
159
  ]
155
160
  pattern = expected_info.map { |r| Regexp.escape(r) }.join('\s+')
156
161
  expect($stdout).to receive(:puts).with(a_string_matching(%r{#{pattern}}m))
@@ -13,7 +13,7 @@ describe 'quoted_booleans', type: :lint do
13
13
  end
14
14
 
15
15
  it 'detects three problems' do
16
- expect(problems).to have(3).problems
16
+ expect(problems.size).to eq(3)
17
17
  end
18
18
 
19
19
  it 'has two warnings' do
@@ -36,7 +36,7 @@ describe 'quoted_booleans', type: :lint do
36
36
  end
37
37
 
38
38
  it 'detects three problems' do
39
- expect(problems).to have(3).problems
39
+ expect(problems.size).to eq(3)
40
40
  end
41
41
 
42
42
  it 'has two warnings' do
@@ -62,7 +62,7 @@ describe 'quoted_booleans', type: :lint do
62
62
  end
63
63
 
64
64
  it 'detects four problems' do
65
- expect(problems).to have(4).problems
65
+ expect(problems.size).to eq(4)
66
66
  end
67
67
 
68
68
  it 'has two warnings' do
@@ -89,7 +89,7 @@ describe 'quoted_booleans', type: :lint do
89
89
  end
90
90
 
91
91
  it 'detects four problems' do
92
- expect(problems).to have(4).problems
92
+ expect(problems.size).to eq(4)
93
93
  end
94
94
 
95
95
  it 'has two warnings' do
@@ -107,7 +107,7 @@ describe 'quoted_booleans', type: :lint do
107
107
  let(:code) { '"true" # lint:ignore:quoted_booleans lint:ignore:double_quoted_string a reason' }
108
108
 
109
109
  it 'detects 1 problems' do
110
- expect(problems).to have(1).problems
110
+ expect(problems.size).to eq(1)
111
111
  end
112
112
 
113
113
  it 'has one ignored problems' do
@@ -129,7 +129,7 @@ describe 'quoted_booleans', type: :lint do
129
129
  end
130
130
 
131
131
  it 'detects 2 problems' do
132
- expect(problems).to have(2).problems
132
+ expect(problems.size).to eq(2)
133
133
  end
134
134
 
135
135
  it 'ignores both problems' do