def check
case_indexes = []
tokens.each_index do |token_idx|
if tokens[token_idx].type == :CASE
depth = 0
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
elsif tokens[idx].type == :RBRACE
depth -= 1
if depth == 0
case_indexes << {:start => token_idx, :end => idx}
break
end
end
end
end
end
case_indexes.each do |kase|
case_tokens = tokens[kase[:start]..kase[:end]]
unless case_tokens.index { |r| r.type == :DEFAULT }
notify :warning, {
:message => 'case statement without a default case',
:line => case_tokens.first.line,
:column => case_tokens.first.column,
}
end
end
end