lib/puppet-lint/plugins/params_not_optional_with_undef.rb
# Returns an array of tokens that cover the data type of the parameter ptok
# Search backwards until we either bump into a comma (whilst not nested), or reach the opening LPAREN
Returns an array of tokens that cover the data type of the parameter ptok
Search backwards until we either bump into a comma (whilst not nested), or reach the opening LPAREN
Returns an array of tokens that cover the data type of the parameter ptok Search backwards until we either bump into a comma ( whilst not nested ) or reach the opening LPAREN
def extract_type_tokens(ptok)
    type_tokens = []
    token = ptok.prev_code_token
    nesting = 0
    while token
      case token.type
      when :LBRACK
        nesting += 1
      when :LPAREN
        nesting += 1
        if nesting.positive?
          first_token = token.next_code_token
          last_token = ptok.prev_code_token
          break
        end
      when :RBRACK, :RPAREN
        nesting -= 1
      when :COMMA
        if nesting.zero?
          first_token = token.next_code_token
          last_token = ptok.prev_code_token
          break
        end
      end
      token = token.prev_code_token
    end
    type_tokens = tokens[tokens.find_index(first_token)..tokens.find_index(last_token)] if first_token && last_token
    type_tokens
  end
def extract_type_tokens ( ptok ) type_tokens = [ ] token = ptok . prev_code_token nesting = 0 while token case token . type when :LBRACK nesting += 1 when :LPAREN nesting += 1 if nesting . positive? first_token = token . next_code_token last_token = ptok . prev_code_token break end when :RBRACK , :RPAREN nesting -= 1 when :COMMA if nesting . zero? first_token = token . next_code_token last_token = ptok . prev_code_token break end end token = token . prev_code_token end type_tokens = tokens [ tokens . find_index ( first_token ) .. tokens . find_index ( last_token ) ] if first_token && last_token type_tokens end
Returns an array of tokens that cover the data type of the parameter ptok
Search backwards until we either bump into a comma (whilst not nested), or reach the opening LPAREN
Returns an array of tokens that cover the data type of the parameter ptok Search backwards until we either bump into a comma ( whilst not nested ) or reach the opening LPAREN
# This is the LPAREN at the start of the parameter list
ptok
<not_specific>