11PuppetLint . new_check ( :check_unsafe_interpolations ) do
2- COMMANDS = Array [ 'command' , 'onlyif' , 'unless' ]
3- INTERPOLATED_STRINGS = Array [ :DQPRE , :DQMID ]
4- USELESS_CHARS = Array [ :WHITESPACE , :COMMA ]
2+ COMMANDS = [ 'command' , 'onlyif' , 'unless' ] . freeze
3+ INTERPOLATED_STRINGS = [ :DQPRE , :DQMID ] . freeze
4+ USELESS_CHARS = [ :WHITESPACE , :COMMA ] . freeze
55 def check
66 # Gather any exec commands' resources into an array
77 exec_resources = resource_indexes . map { |resource |
88 resource_parameters = resource [ :param_tokens ] . map ( &:value )
9- resource if resource [ :type ] . value == 'exec' && !( COMMANDS & resource_parameters ) . empty ?
9+ resource if resource [ :type ] . value == 'exec' && !COMMANDS . intersect? ( resource_parameters ) . nil ?
1010 } . compact
1111
1212 # Iterate over title tokens and raise a warning if any are variables
@@ -33,7 +33,7 @@ def check_unsafe_title(title)
3333 def check_unsafe_interpolations ( command_resources )
3434 command_resources [ :tokens ] . each do |token |
3535 # Skip iteration if token isn't a command of type :NAME
36- next unless COMMANDS . include? ( token . value ) && ( token . type == :NAME || token . type == :UNLESS )
36+ next unless COMMANDS . include? ( token . value ) && [ :NAME , :UNLESS ] . include? ( token . type )
3737 # Don't check the command if it is parameterised
3838 next if parameterised? ( token )
3939
@@ -106,7 +106,7 @@ def get_exec_titles
106106 result << tokens [ title_start_idx ..title_end_idx ]
107107 # Title is in single quotes
108108 else
109- tokens_array . concat ( [ tokens [ token_idx ] . next_code_token . next_code_token ] )
109+ tokens_array . push ( tokens [ token_idx ] . next_code_token . next_code_token )
110110
111111 result << tokens_array
112112 end
0 commit comments