puppet-lint 4.2.0 → 4.2.1
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 +4 -4
- data/README.md +18 -4
- data/lib/puppet-lint/lexer.rb +2 -2
- data/lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb +2 -2
- data/lib/puppet-lint/plugins/top_scope_facts/top_scope_facts.rb +4 -4
- data/lib/puppet-lint/version.rb +1 -1
- data/rubocop_baseline.yml +7 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/puppet-lint/checks_spec.rb +7 -2
- data/spec/unit/puppet-lint/ignore_overrides_spec.rb +6 -6
- data/spec/unit/puppet-lint/lexer_spec.rb +702 -699
- data/spec/unit/puppet-lint/plugins/check_classes/arrow_on_right_operand_line_spec.rb +5 -5
- data/spec/unit/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +8 -8
- data/spec/unit/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb +2 -1
- data/spec/unit/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +3 -3
- data/spec/unit/puppet-lint/plugins/check_classes/name_contains_uppercase_spec.rb +3 -3
- data/spec/unit/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +3 -3
- data/spec/unit/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +5 -5
- data/spec/unit/puppet-lint/plugins/check_classes/parameter_order_spec.rb +14 -14
- data/spec/unit/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_classes/variable_scope_spec.rb +21 -21
- data/spec/unit/puppet-lint/plugins/check_comments/slash_comments_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_comments/star_comments_spec.rb +4 -4
- data/spec/unit/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +6 -6
- data/spec/unit/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_documentation/documentation_spec.rb +5 -5
- data/spec/unit/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +11 -11
- data/spec/unit/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +6 -6
- data/spec/unit/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +12 -12
- data/spec/unit/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +4 -4
- data/spec/unit/puppet-lint/plugins/check_resources/file_mode_spec.rb +22 -22
- data/spec/unit/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +8 -8
- data/spec/unit/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +13 -13
- data/spec/unit/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +18 -18
- data/spec/unit/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +6 -6
- data/spec/unit/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +4 -4
- data/spec/unit/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +8 -8
- data/spec/unit/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +3 -3
- data/spec/unit/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +7 -7
- data/spec/unit/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_variables/variable_is_lowercase_spec.rb +5 -5
- data/spec/unit/puppet-lint/plugins/check_whitespace/140chars_spec.rb +4 -4
- data/spec/unit/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +1 -1
- data/spec/unit/puppet-lint/plugins/check_whitespace/80chars_spec.rb +4 -4
- data/spec/unit/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +37 -37
- data/spec/unit/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +6 -6
- data/spec/unit/puppet-lint/plugins/legacy_facts/legacy_facts_spec.rb +83 -75
- data/spec/unit/puppet-lint/plugins/top_scope_facts/top_scope_facts_spec.rb +19 -19
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8fbf6d28ee384ac72918e39f7a578ccbca81041749e612b9d9ead33a72f7e57
|
4
|
+
data.tar.gz: 358cdd9a1c4c1c71986b868897855cd6410a538fdff6f8f625fd60007fe062e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0073f5e753d913b7d3fc324646bd04fb46eac444ffe6111422f3b2fddbc7008737d4774ce29bfe7b34e946bbcd3301d0d66836ab04ecc88e4f21198eaa4c192e
|
7
|
+
data.tar.gz: 67f83fcafd14cc225c43f64ddb8326f88a37225700058e83bf2d22fc0a5915bb1096b6e46557c7a88c3e0210bd36ed171136eacef0722e1bb2aa20935efa3b8f
|
data/README.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# Puppet Lint
|
2
2
|
|
3
|
+
[](https://github.com/puppetlabs/puppet-lint/blob/main/CODEOWNERS)
|
4
|
+

|
5
|
+

|
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
|
-
|
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
|
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
|
data/lib/puppet-lint/lexer.rb
CHANGED
@@ -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/
|
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/
|
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 =
|
120
|
-
fact_name = match[
|
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
|
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
|
-
|
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
|
-
|
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{^::(#{
|
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, {
|
data/lib/puppet-lint/version.rb
CHANGED
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
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
132
|
+
expect(problems.size).to eq(2)
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'ignores both problems' do
|