Skip to content

Commit 43fc623

Browse files
committed
Do not crash on a typoed legacy fact hash syntax (i.e., missing closing quote)
1 parent df127fe commit 43fc623

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ def check
117117

118118
# This matches legacy facts defined in the fact hash that use the top scope
119119
# fact assignment.
120-
if token.value.start_with?("::facts['")
121-
fact_name = token.value.match(%r{::facts\['(.*)'\]})[1]
120+
if token.value.match(%r{::facts\['(.*)'\]})
121+
fact_name = token.value.match(%r{::facts\['(.*)'\]})[1]
122122

123123
# This matches legacy facts defined in the fact hash.
124-
elsif token.value.start_with?("facts['")
125-
fact_name = token.value.match(%r{facts\['(.*)'\]})[1]
124+
elsif token.value.match(%r{facts\['(.*)'\]})
125+
fact_name = token.value.match(%r{facts\['(.*)'\]})[1]
126126

127127
# This matches using legacy facts in a the new structured fact. For
128128
# example this would match 'uuid' in $facts['uuid'] so it can be converted

0 commit comments

Comments
 (0)