lib/puppet-lint/plugins/check-params_empty_string_assignment.rb
# Returns array of tokens that cover the value that the parameter token has as its default
# Search forward to find value assigned to this parameter
# We want to find the thing after `=` and before `,`
Returns array of tokens that cover the value that the parameter token has as its default
Search forward to find value assigned to this parameter
We want to find the thing after `=` and before `,`
Returns array of tokens that cover the value that the parameter token has as its default Search forward to find value assigned to this parameter We want to find the thing after ` = ` and before ` `
def extract_default_value_tokens(ptok)
    value_tokens = []
    token = ptok.next_code_token
    nesting = 0
    while token
      case token.type
      when :LPAREN, :LBRACK
        nesting += 1
      when :RBRACK
        nesting -= 1
      when :RPAREN
        nesting -= 1
        if nesting.negative?
          last_token = token.prev_code_token
          break
        end
      when :EQUALS
        first_token = token.next_code_token
      when :COMMA
        unless nesting.positive?
          last_token = token.prev_code_token
          break
        end
      end
      token = token.next_token
    end
    value_tokens = tokens[tokens.find_index(first_token)..tokens.find_index(last_token)] if first_token && last_token
    value_tokens
  end
def extract_default_value_tokens ( ptok ) value_tokens = [ ] token = ptok . next_code_token nesting = 0 while token case token . type when :LPAREN , :LBRACK nesting += 1 when :RBRACK nesting -= 1 when :RPAREN nesting -= 1 if nesting . negative? last_token = token . prev_code_token break end when :EQUALS first_token = token . next_code_token when :COMMA unless nesting . positive? last_token = token . prev_code_token break end end token = token . next_token end value_tokens = tokens [ tokens . find_index ( first_token ) .. tokens . find_index ( last_token ) ] if first_token && last_token value_tokens end
Returns array of tokens that cover the value that the parameter token has as its default
Search forward to find value assigned to this parameter
We want to find the thing after `=` and before `,`
Returns array of tokens that cover the value that the parameter token has as its default Search forward to find value assigned to this parameter We want to find the thing after ` = ` and before ` `
# This is the RPAREN at the end of the parameters. There wasn't a COMMA
ptok
<not_specific>