Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#notify_tokens(type, sep_type, message) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet-lint/plugins/check_unquoted_string_in_case.rb', line 26 def notify_tokens(type, sep_type, ) type_indexes(type).each do |kase| type_tokens = tokens[kase[:start]..kase[:end]] type_tokens.index do |r| if r.type == sep_type s = r.prev_token while (s.type != :NEWLINE) && (s.type != :LBRACE) if s.type == :NAME || (s.type == :CLASSREF && !s.value.include?('::')) notify :warning, { message: , line: s.line, column: s.column, token: s, } end s = s.prev_token end end end end end |
#type_indexes(type) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet-lint/plugins/check_unquoted_string_in_case.rb', line 1 def type_indexes(type) type_indexes = [] tokens.each_index do |token_idx| next unless tokens[token_idx].type == type depth = 0 start = token_idx tokens[(token_idx + 1)..-1].each_index do |case_token_idx| idx = case_token_idx + token_idx + 1 if tokens[idx].type == :LBRACE depth += 1 type_indexes << { start: start, end: idx } if depth == 2 elsif tokens[idx].type == :RBRACE start = idx if depth == 2 depth -= 1 if depth == 0 type_indexes << { start: start, end: idx } break end end end end type_indexes end |