puppet-lint 4.3.0 → 5.0.0

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/puppet-lint/checkplugin.rb +3 -3
  3. data/lib/puppet-lint/checks.rb +6 -3
  4. data/lib/puppet-lint/configuration.rb +1 -1
  5. data/lib/puppet-lint/data.rb +1 -1
  6. data/lib/puppet-lint/lexer/string_slurper.rb +6 -6
  7. data/lib/puppet-lint/lexer.rb +40 -3
  8. data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +1 -1
  9. data/lib/puppet-lint/plugins/check_comments/slash_comments.rb +1 -1
  10. data/lib/puppet-lint/plugins/check_comments/star_comments.rb +1 -1
  11. data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +1 -1
  12. data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +1 -1
  13. data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +1 -1
  14. data/lib/puppet-lint/plugins/check_resources/file_mode.rb +1 -1
  15. data/lib/puppet-lint/plugins/check_resources/unquoted_resource_title.rb +1 -1
  16. data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +2 -2
  17. data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +2 -2
  18. data/lib/puppet-lint/plugins/check_strings/puppet_url_without_modules.rb +1 -1
  19. data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +1 -1
  20. data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +1 -1
  21. data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +1 -1
  22. data/lib/puppet-lint/plugins/check_whitespace/space_before_arrow.rb +2 -2
  23. data/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb +1 -1
  24. data/lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb +2 -2
  25. data/lib/puppet-lint/plugins/top_scope_facts/top_scope_facts.rb +1 -1
  26. data/lib/puppet-lint/plugins.rb +1 -1
  27. data/lib/puppet-lint/report/codeclimate.rb +1 -1
  28. data/lib/puppet-lint/tasks/puppet-lint.rb +2 -2
  29. data/lib/puppet-lint/tasks/release_test.rb +2 -2
  30. data/lib/puppet-lint/version.rb +1 -1
  31. data/lib/puppet-lint.rb +2 -3
  32. data/rubocop_baseline.yml +1 -1
  33. data/spec/acceptance/puppet_lint_spec.rb +7 -0
  34. data/spec/fixtures/test/manifests/parseable.yaml +3 -0
  35. data/spec/spec_helper.rb +3 -2
  36. data/spec/unit/puppet-lint/checks_spec.rb +0 -5
  37. data/spec/unit/puppet-lint/lexer_spec.rb +6 -0
  38. metadata +5 -5
  39. data/lib/puppet-lint/monkeypatches.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe9befaf41d2eaff6047b13dc030938b29002ce29382312862571133e1b75138
4
- data.tar.gz: 655bc012b63ae3659262cfeea02c4e9b35c1af65a1831c5df839b30ea3307934
3
+ metadata.gz: 4f8119856eb91c58047532aa02757d8b4904120ad6401a3af2b385a1a40aa321
4
+ data.tar.gz: 870ad4f57b3c1dfcf40207af7a84d5afc18ec388bb520e362e6d8bafbd647205
5
5
  SHA512:
6
- metadata.gz: e6684deef64a18afb534b4004106fc946bcb67e4f8d406912b2bdf0851c495b1feaf35938268c7f1854686e2114c803f7f31b37a9d61df85d175cbf8eb8df14d
7
- data.tar.gz: 92f9e92fb27df8abe9b28c116eefa9f901a64b13b6e0de98c6a39cd58451f726ceb142e85daa1958fad2d88388505634d18bee02cc242e023e1bdab51b5a9943
6
+ metadata.gz: 76294db75e44acc05da97c12f26f5dae32d358e4b0e254c92bda9a0d3f9948d0e07b2d6a6e615e238457214ea85f22e2d499e15184ad1b747665d63d667bdc80
7
+ data.tar.gz: 5d2402a687836436ceb7a63d7510d28acb6e594a399d2904cc2a2215d14971b006642cfb8a89365833af5a7307c08e44759e980870bd75e828944920e5149bc3
@@ -180,9 +180,9 @@ class PuppetLint::CheckPlugin
180
180
  def default_info
181
181
  @default_info ||= {
182
182
  check: self.class.const_get(:NAME),
183
- fullpath: fullpath,
184
- path: path,
185
- filename: filename
183
+ fullpath:,
184
+ path:,
185
+ filename:
186
186
  }
187
187
  end
188
188
 
@@ -36,7 +36,7 @@ class PuppetLint::Checks
36
36
  problems << {
37
37
  kind: :error,
38
38
  check: :syntax,
39
- message: message,
39
+ message:,
40
40
  line: e.line_no,
41
41
  column: e.column,
42
42
  fullpath: PuppetLint::Data.fullpath,
@@ -54,10 +54,11 @@ class PuppetLint::Checks
54
54
  #
55
55
  # Returns an Array of problem Hashes.
56
56
  def run(fileinfo, data)
57
- load_data(fileinfo, data)
58
-
59
57
  checks_run = []
60
58
  if File.extname(fileinfo).downcase.match?(%r{\.ya?ml$})
59
+ PuppetLint::Data.path = fileinfo
60
+ PuppetLint::Data.manifest_lines = data.split("\n", -1)
61
+
61
62
  enabled_checks.select { |check| YAML_COMPATIBLE_CHECKS.include?(check) }.each do |check|
62
63
  klass = PuppetLint.configuration.check_object[check].new
63
64
  # FIXME: shadowing #problems
@@ -65,6 +66,8 @@ class PuppetLint::Checks
65
66
  checks_run << [klass, problems]
66
67
  end
67
68
  else
69
+ load_data(fileinfo, data)
70
+
68
71
  enabled_checks.each do |check|
69
72
  klass = PuppetLint.configuration.check_object[check].new
70
73
  # FIXME: shadowing #problems
@@ -48,7 +48,7 @@ class PuppetLint::Configuration
48
48
  # Signature
49
49
  #
50
50
  # <option>=(value)
51
- def method_missing(method, *args, &_block)
51
+ def method_missing(method, *args, &)
52
52
  super unless method.to_s =~ %r{^(\w+)=?$}
53
53
 
54
54
  option = Regexp.last_match(1)
@@ -359,7 +359,7 @@ class PuppetLint::Data
359
359
  end: i + j + 1,
360
360
  tokens: tokens[i..(i + j + 1)],
361
361
  param_tokens: param_tokens(tokens[i..(i + j + 1)]),
362
- type: type,
362
+ type:,
363
363
  name_token: token.next_code_token,
364
364
  inherited_token: inherited_class
365
365
  }
@@ -6,12 +6,12 @@ class PuppetLint::Lexer
6
6
  class StringSlurper
7
7
  attr_accessor :scanner, :results, :interp_stack
8
8
 
9
- START_INTERP_PATTERN = %r{\$\{}.freeze
10
- END_INTERP_PATTERN = %r{\}}.freeze
11
- END_STRING_PATTERN = %r{(\A|[^\\])(\\\\)*"}.freeze
12
- UNENC_VAR_PATTERN = %r{(\A|[^\\])\$(::)?(\w+(-\w+)*::)*\w+(-\w+)*}.freeze
13
- ESC_DQUOTE_PATTERN = %r{\\+"}.freeze
14
- LBRACE_PATTERN = %r{\{}.freeze
9
+ START_INTERP_PATTERN = %r{\$\{}
10
+ END_INTERP_PATTERN = %r{\}}
11
+ END_STRING_PATTERN = %r{(\A|[^\\])(\\\\)*"}
12
+ UNENC_VAR_PATTERN = %r{(\A|[^\\])\$(::)?(\w+(-\w+)*::)*\w+(-\w+)*}
13
+ ESC_DQUOTE_PATTERN = %r{\\+"}
14
+ LBRACE_PATTERN = %r{\{}
15
15
 
16
16
  def initialize(string)
17
17
  @scanner = StringScanner.new(string)
@@ -111,9 +111,9 @@ class PuppetLint::Lexer
111
111
  # \p{Zs} == ASCII + Unicode non-linebreaking whitespace
112
112
  WHITESPACE_RE = (RUBY_VERSION == '1.8.7') ? %r{[\t\v\f ]} : %r{[\t\v\f\p{Zs}]}
113
113
 
114
- LINE_END_RE = %r{(?:\r\n|\r|\n)}.freeze
114
+ LINE_END_RE = %r{(?:\r\n|\r|\n)}
115
115
 
116
- NAME_RE = %r{\A((?:(?:::)?[_a-z0-9][-\w]*)(?:::[a-z0-9][-\w]*)*)}.freeze
116
+ NAME_RE = %r{\A((?:(?:::)?[_a-z0-9][-\w]*)(?:::[a-z0-9][-\w]*)*)}
117
117
 
118
118
  # Internal: An Array of Arrays containing tokens that can be described by
119
119
  # a single regular expression. Each sub-Array contains 2 elements, the
@@ -123,7 +123,44 @@ class PuppetLint::Lexer
123
123
  [:WHITESPACE, %r{\A(#{WHITESPACE_RE}+)}],
124
124
  # FIXME: Future breaking change, the following :TYPE tokens conflict with
125
125
  # the :TYPE keyword token.
126
- [:TYPE, %r{\A(Any|Array|Binary|Boolean|Callable|CatalogEntry|Class|Collection|Data|Default|Enum|Error|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|Sensitive|String|Struct|Tuple|Type|Undef|Variant)\b}], # rubocop:disable Layout/LineLength
126
+ [:TYPE, %r{\A(
127
+ Any|
128
+ Array|
129
+ Binary|
130
+ Boolean|
131
+ Callable|
132
+ CatalogEntry|
133
+ Class|
134
+ Collection|
135
+ Data|
136
+ Default|
137
+ Enum|
138
+ Error|
139
+ Float|
140
+ Hash|
141
+ Integer|
142
+ Iterable|
143
+ Iterator|
144
+ NotUndef|
145
+ Numeric|
146
+ Optional|
147
+ Pattern|
148
+ Regexp|
149
+ Resource|
150
+ RichData|
151
+ Runtime|
152
+ Scalar|
153
+ ScalarData|
154
+ SemVer|
155
+ SemVerRange|
156
+ Sensitive|
157
+ String|
158
+ Struct|
159
+ Tuple|
160
+ Type|
161
+ Undef|
162
+ Variant
163
+ )\b}x],
127
164
  [:CLASSREF, %r{\A(((::){0,1}[A-Z][-\w]*)+)}],
128
165
  [:NUMBER, %r{\A\b((?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d+)?(?:[eE]-?\d+)?))\b}],
129
166
  [:FUNCTION_NAME, %r{#{NAME_RE}(?=\()}],
@@ -12,7 +12,7 @@ PuppetLint.new_check(:arrow_on_right_operand_line) do
12
12
  message: "arrow should be on the right operand's line",
13
13
  line: token.line,
14
14
  column: token.column,
15
- token: token,
15
+ token:,
16
16
  description: 'Test the manifest tokens for chaining arrow that is on the line of the left operand when the right operand is on another line.',
17
17
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#chaining-arrow-syntax',
18
18
  )
@@ -12,7 +12,7 @@ PuppetLint.new_check(:slash_comments) do
12
12
  message: '// comment found',
13
13
  line: token.line,
14
14
  column: token.column,
15
- token: token,
15
+ token:,
16
16
  description: 'Check the manifest tokens for any comments started with slashes (//) and record a warning for each instance found.',
17
17
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#comments',
18
18
  )
@@ -12,7 +12,7 @@ PuppetLint.new_check(:star_comments) do
12
12
  message: '/* */ comment found',
13
13
  line: token.line,
14
14
  column: token.column,
15
- token: token,
15
+ token:,
16
16
  description: 'Check the manifest tokens for any comments encapsulated with slash-asterisks (/* */) and record a warning for each instance found.',
17
17
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#comments',
18
18
  )
@@ -31,7 +31,7 @@ PuppetLint.new_check(:unquoted_node_name) do
31
31
  message: 'unquoted node name found',
32
32
  line: token.line,
33
33
  column: token.column,
34
- token: token,
34
+ token:,
35
35
  description: 'Check the manifest for unquoted node names and record a warning for each instance found.',
36
36
  help_uri: nil,
37
37
  )
@@ -20,7 +20,7 @@ PuppetLint.new_check(:ensure_first_param) do
20
20
  message: "ensure found on line but it's not the first attribute",
21
21
  line: ensure_token.line,
22
22
  column: ensure_token.column,
23
- resource: resource,
23
+ resource:,
24
24
  description: 'Check the tokens of each resource instance for an ensure parameter and if ' \
25
25
  'found, check that it is the first parameter listed. If it is not the first parameter, record a warning.',
26
26
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#attribute-ordering',
@@ -20,7 +20,7 @@ PuppetLint.new_check(:ensure_not_symlink_target) do
20
20
  line: value_token.line,
21
21
  column: value_token.column,
22
22
  param_token: ensure_token,
23
- value_token: value_token,
23
+ value_token:,
24
24
  description: 'Check the tokens of each File resource instance for an ensure parameter and ' \
25
25
  'record a warning if the value of that parameter looks like a symlink target (starts with a \'/\').',
26
26
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#symbolic-links',
@@ -6,7 +6,7 @@
6
6
  MSG = 'mode should be represented as a 4 digit octal value or symbolic mode'.freeze
7
7
  SYM_RE = '([ugoa]*[-=+][-=+rstwxXugo]*)(,[ugoa]*[-=+][-=+rstwxXugo]*)*'.freeze
8
8
  IGNORE_TYPES = Set[:VARIABLE, :UNDEF, :FUNCTION_NAME]
9
- MODE_RE = %r{\A([0-7]{4}|#{SYM_RE})\Z}.freeze
9
+ MODE_RE = %r{\A([0-7]{4}|#{SYM_RE})\Z}
10
10
 
11
11
  PuppetLint.new_check(:file_mode) do
12
12
  def check
@@ -12,7 +12,7 @@ PuppetLint.new_check(:unquoted_resource_title) do
12
12
  message: 'unquoted resource title',
13
13
  line: token.line,
14
14
  column: token.column,
15
- token: token,
15
+ token:,
16
16
  description: 'Check the manifest tokens for any resource titles / namevars that are not quoted and record a warning for each instance found.',
17
17
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#resource-names',
18
18
  )
@@ -3,7 +3,7 @@
3
3
  # each instance found.
4
4
  #
5
5
  # https://puppet.com/docs/puppet/latest/style_guide.html#quoting
6
- ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\\s|\n|\\n|\\\\)}.freeze
6
+ ESCAPE_CHAR_RE = %r{(\\\$|\\"|\\'|'|\r|\t|\\t|\\s|\n|\\n|\\\\)}
7
7
 
8
8
  PuppetLint.new_check(:double_quoted_strings) do
9
9
  def check
@@ -18,7 +18,7 @@ PuppetLint.new_check(:double_quoted_strings) do
18
18
  message: 'double quoted string containing no variables',
19
19
  line: token.line,
20
20
  column: token.column,
21
- token: token,
21
+ token:,
22
22
  description: 'Check the manifest tokens for any double quoted strings that don\'t ' \
23
23
  'contain any variables or common escape characters and record a warning for each instance found.',
24
24
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
@@ -27,8 +27,8 @@ PuppetLint.new_check(:only_variable_string) do
27
27
  message: 'string containing only a variable',
28
28
  line: var_token.line,
29
29
  column: var_token.column,
30
- start_token: start_token,
31
- var_token: var_token,
30
+ start_token:,
31
+ var_token:,
32
32
  end_token: eos_token,
33
33
  description: 'Check the manifest tokens for double quoted strings that contain a single variable only and record a warning for each instance found.',
34
34
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
@@ -19,7 +19,7 @@ PuppetLint.new_check(:puppet_url_without_modules) do
19
19
  message: 'puppet:// URL without modules/ found',
20
20
  line: token.line,
21
21
  column: token.column,
22
- token: token,
22
+ token:,
23
23
  description: 'Check the manifest tokens for any puppet:// URL strings where the path section doesn\'t start with modules/ and record a warning for each instance found.',
24
24
  help_uri: nil,
25
25
  )
@@ -18,7 +18,7 @@ PuppetLint.new_check(:quoted_booleans) do
18
18
  message: 'quoted boolean value found',
19
19
  line: token.line,
20
20
  column: token.column,
21
- token: token,
21
+ token:,
22
22
  description: 'Check the manifest tokens for any double or single quoted strings containing only a boolean value and record a warning for each instance found.',
23
23
  help_uri: nil,
24
24
  )
@@ -25,7 +25,7 @@ PuppetLint.new_check(:variables_not_enclosed) do
25
25
  message: 'variable not enclosed in {}',
26
26
  line: token.line,
27
27
  column: token.column,
28
- token: token,
28
+ token:,
29
29
  description: 'Check the manifest tokens for any variables in a string that have not been enclosed by braces ({}) and record a warning for each instance found.',
30
30
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#quoting',
31
31
  )
@@ -16,7 +16,7 @@ PuppetLint.new_check(:hard_tabs) do
16
16
  message: 'tab character found',
17
17
  line: token.line,
18
18
  column: token.column,
19
- token: token,
19
+ token:,
20
20
  description: 'Check the raw manifest string for lines containing hard tab characters and record an error for each instance found.',
21
21
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace',
22
22
  )
@@ -51,8 +51,8 @@ PuppetLint.new_check(:space_before_arrow) do
51
51
  notify(
52
52
  :warning,
53
53
  message: "there should be a single space before '=>' on line #{line}, column #{column}",
54
- line: line,
55
- column: column,
54
+ line:,
55
+ column:,
56
56
  token: prev_token,
57
57
  )
58
58
  end
@@ -18,7 +18,7 @@ PuppetLint.new_check(:trailing_whitespace) do
18
18
  message: 'trailing whitespace found',
19
19
  line: token.line,
20
20
  column: token.column,
21
- token: token,
21
+ token:,
22
22
  description: 'Check the manifest tokens for lines ending with whitespace and record an error for each instance found.',
23
23
  help_uri: 'https://puppet.com/docs/puppet/latest/style_guide.html#spacing-indentation-and-whitespace',
24
24
  )
@@ -184,8 +184,8 @@ PuppetLint.new_check(:legacy_facts) do
184
184
  message: "legacy fact '#{fact_name}'",
185
185
  line: token.line,
186
186
  column: token.column,
187
- token: token,
188
- fact_name: fact_name
187
+ token:,
188
+ fact_name:
189
189
  }
190
190
  end
191
191
  end
@@ -38,7 +38,7 @@ PuppetLint.new_check(:top_scope_facts) do
38
38
  message: 'top scope fact instead of facts hash',
39
39
  line: token.line,
40
40
  column: token.column,
41
- token: token
41
+ token:
42
42
  }
43
43
  end
44
44
  end
@@ -75,7 +75,7 @@ class PuppetLint::Plugins
75
75
  end
76
76
  end
77
77
 
78
- Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].sort.each do |file|
78
+ Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].each do |file|
79
79
  require file
80
80
  end
81
81
 
@@ -25,7 +25,7 @@ class PuppetLint::Report
25
25
  check_name: message[:check],
26
26
  description: message[:message],
27
27
  categories: [:Style],
28
- severity: severity,
28
+ severity:,
29
29
  location: {
30
30
  path: message[:path],
31
31
  lines: {
@@ -27,7 +27,7 @@ class PuppetLint::RakeTask < Rake::TaskLib
27
27
  #
28
28
  # PuppetLint::RakeTask.new
29
29
  # rubocop:disable Lint/MissingSuper
30
- def initialize(*args, &task_block)
30
+ def initialize(*args, &)
31
31
  @name = args.shift || :lint
32
32
  @pattern = DEFAULT_PATTERN
33
33
  @with_filename = true
@@ -35,7 +35,7 @@ class PuppetLint::RakeTask < Rake::TaskLib
35
35
  @only_checks = []
36
36
  @ignore_paths = []
37
37
 
38
- define(args, &task_block)
38
+ define(args, &)
39
39
  end
40
40
 
41
41
  def define(args, &task_block)
@@ -27,7 +27,7 @@ def run_cmd(message, *cmd)
27
27
  [output.strip, status.success?]
28
28
  end
29
29
 
30
- def with_puppet_lint_head(&block)
30
+ def with_puppet_lint_head(&)
31
31
  print(' Updating Gemfile to use puppet-lint HEAD... ')
32
32
 
33
33
  buffer = Parser::Source::Buffer.new('Gemfile')
@@ -49,7 +49,7 @@ def with_puppet_lint_head(&block)
49
49
 
50
50
  puts 'Done'
51
51
 
52
- Bundler.with_clean_env(&block)
52
+ Bundler.with_clean_env(&)
53
53
 
54
54
  run_cmd('Restoring Gemfile', 'git', 'checkout', '--', 'Gemfile')
55
55
  end
@@ -1,3 +1,3 @@
1
1
  class PuppetLint
2
- VERSION = '4.3.0'.freeze
2
+ VERSION = '5.0.0'.freeze
3
3
  end
data/lib/puppet-lint.rb CHANGED
@@ -11,7 +11,6 @@ require 'puppet-lint/data'
11
11
  require 'puppet-lint/checks'
12
12
  require 'puppet-lint/report/github'
13
13
  require 'puppet-lint/bin'
14
- require 'puppet-lint/monkeypatches'
15
14
 
16
15
  class PuppetLint::NoCodeError < StandardError; end
17
16
 
@@ -250,11 +249,11 @@ class PuppetLint
250
249
  # def check
251
250
  # end
252
251
  # end
253
- def self.new_check(name, &block)
252
+ def self.new_check(name, &)
254
253
  class_name = name.to_s.split('_').map(&:capitalize).join
255
254
  klass = PuppetLint.const_set(:"Check#{class_name}", Class.new(PuppetLint::CheckPlugin))
256
255
  klass.const_set(:NAME, name)
257
- klass.class_exec(&block)
256
+ klass.class_exec(&)
258
257
  PuppetLint.configuration.add_check(name, klass)
259
258
  PuppetLint::Data.ignore_overrides[name] ||= {}
260
259
  end
data/rubocop_baseline.yml CHANGED
@@ -6,7 +6,7 @@ AllCops:
6
6
  NewCops: enable
7
7
  ExtraDetails: true
8
8
  DisplayStyleGuide: true
9
- TargetRubyVersion: '2.7'
9
+ TargetRubyVersion: '3.1'
10
10
  DisplayCopNames: true
11
11
  SuggestExtensions: false
12
12
  Exclude:
@@ -43,4 +43,11 @@ describe 'When executing puppet-lint' do
43
43
  expect(result[:stdout]).to have_warnings(2)
44
44
  end
45
45
  end
46
+
47
+ context 'with a YAML file provided' do
48
+ it 'returns zero errors' do
49
+ result = puppet_lint([File.join(manifest_root, 'parseable.yaml')])
50
+ expect(result[:stdout]).to have_errors(0)
51
+ end
52
+ end
46
53
  end
@@ -0,0 +1,3 @@
1
+ ---
2
+ heredoc: |
3
+ contains $
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ end
22
22
 
23
23
  require 'puppet-lint'
24
24
  require 'rspec/its'
25
+ require 'pp'
25
26
  begin
26
27
  require 'rspec/json_expectations'
27
28
  rescue LoadError, SyntaxError
@@ -33,7 +34,7 @@ module RSpec::LintExampleGroup
33
34
  def initialize(method, message)
34
35
  @expected_problem = {
35
36
  kind: method.to_s.delete_prefix('contain_').to_sym,
36
- message: message
37
+ message:
37
38
  }
38
39
  @description = ["contain a #{@expected_problem[:kind]}"]
39
40
  end
@@ -107,7 +108,7 @@ module RSpec::LintExampleGroup
107
108
  end
108
109
  end
109
110
 
110
- def method_missing(method, *args, &block)
111
+ def method_missing(method, *args, &)
111
112
  return HaveProblem.new(method, args.first) if method.to_s.start_with?('contain_')
112
113
 
113
114
  super
@@ -223,11 +223,6 @@ describe PuppetLint::Checks do
223
223
  allow(File).to receive(:extname).with(fileinfo).and_return('.yaml')
224
224
  end
225
225
 
226
- it 'loads the yaml data' do
227
- expect(instance).to receive(:load_data).with(fileinfo, data).and_call_original # rubocop: disable RSpec/SubjectStub
228
- instance.run(fileinfo, data)
229
- end
230
-
231
226
  context 'when there are checks enabled' do
232
227
  let(:enabled_checks) { [:legacy_facts] }
233
228
  let(:enabled_check_classes) { enabled_checks.map { |r| PuppetLint.configuration.check_object[r] } }
@@ -1392,6 +1392,12 @@ END
1392
1392
 
1393
1393
  it_behaves_like 'a type matcher', 'Error'
1394
1394
  it_behaves_like 'a type matcher', 'Binary'
1395
+ it_behaves_like 'a type matcher', 'Iterable'
1396
+ it_behaves_like 'a type matcher', 'Iterator'
1397
+ it_behaves_like 'a type matcher', 'RichData'
1398
+ it_behaves_like 'a type matcher', 'ScalarData'
1399
+ it_behaves_like 'a type matcher', 'SemVer'
1400
+ it_behaves_like 'a type matcher', 'SemVerRange'
1395
1401
  end
1396
1402
 
1397
1403
  context ':HEREDOC without interpolation' do
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.3.0
4
+ version: 5.0.0
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: 2025-03-06 00:00:00.000000000 Z
13
+ date: 2025-09-23 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"
@@ -34,7 +34,6 @@ files:
34
34
  - lib/puppet-lint/lexer.rb
35
35
  - lib/puppet-lint/lexer/string_slurper.rb
36
36
  - lib/puppet-lint/lexer/token.rb
37
- - lib/puppet-lint/monkeypatches.rb
38
37
  - lib/puppet-lint/optparser.rb
39
38
  - lib/puppet-lint/plugins.rb
40
39
  - lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb
@@ -95,6 +94,7 @@ files:
95
94
  - spec/fixtures/test/manifests/init.pp
96
95
  - spec/fixtures/test/manifests/malformed.pp
97
96
  - spec/fixtures/test/manifests/mismatched_control_comment.pp
97
+ - spec/fixtures/test/manifests/parseable.yaml
98
98
  - spec/fixtures/test/manifests/top_scope_variables.pp
99
99
  - spec/fixtures/test/manifests/two_warnings.pp
100
100
  - spec/fixtures/test/manifests/unterminated_control_comment.pp
@@ -165,14 +165,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
- version: '2.7'
168
+ version: '3.1'
169
169
  required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubygems_version: 3.1.6
175
+ rubygems_version: 3.3.27
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Ensure your Puppet manifests conform with the Puppetlabs style guide
@@ -1,51 +0,0 @@
1
- begin
2
- '%{test}' % { test: 'replaced' } == 'replaced'
3
- rescue StandardError
4
- # monkeypatch String#% into Ruby 1.8.7
5
- class String
6
- Percent = instance_method(:%) unless defined?(Percent)
7
-
8
- def %(*a, &b)
9
- a.flatten!
10
-
11
- string = case a.last
12
- when Hash
13
- expand(a.pop)
14
- else
15
- self
16
- end
17
-
18
- if a.empty?
19
- string
20
- else
21
- Percent.bind_call(string, a, &b)
22
- end
23
- end
24
-
25
- def expand!(vars = {})
26
- loop do
27
- changed = false
28
- vars.each do |var, value|
29
- var = var.to_s
30
- var.gsub!(%r{[^a-zA-Z0-9_]}, '')
31
- changed = gsub!(%r{%\{#{var}\}}, value.to_s)
32
- end
33
- break unless changed
34
- end
35
- self
36
- end
37
-
38
- def expand(opts = {})
39
- dup.expand!(opts)
40
- end
41
- end
42
- end
43
-
44
- unless String.respond_to?(:prepend)
45
- # monkeypatch String#prepend into Ruby 1.8.7
46
- class String
47
- def prepend(lead)
48
- replace("#{lead}#{self}")
49
- end
50
- end
51
- end