Skip to content

Commit e9b28f9

Browse files
authored
Merge pull request #19 from puppetlabs/CONT-234_refactor-nested-loops
2 parents 652577f + 52becf3 commit e9b28f9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/puppet-lint/plugins/check_unsafe_interpolations.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ def check
1919

2020
# Iterate over each command found in any exec
2121
exec_resources.each do |command_resources|
22-
# Iterate over each command in execs and check for unsafe interpolations
23-
command_resources[:tokens].each do |token|
24-
# We are only interested in tokens from command onwards
25-
next unless token.type == :NAME
26-
# Don't check the command if it is parameterised
27-
next if parameterised?(token)
22+
check_unsafe_interpolations(command_resources)
23+
end
24+
end
2825

29-
check_command(token).each do |t|
30-
notify_warning(t)
31-
end
26+
# Iterates over tokens in a command and raises a warning if an interpolated variable is found
27+
def check_unsafe_interpolations(command_resources)
28+
command_resources[:tokens].each do |token|
29+
# We are only interested in tokens from command onwards
30+
next unless token.type == :NAME
31+
# Don't check the command if it is parameterised
32+
next if parameterised?(token)
33+
34+
check_command(token).each do |t|
35+
notify_warning(t)
3236
end
3337
end
3438
end

0 commit comments

Comments
 (0)