lib/rubocop/cop/brace_after_percent.rb in rubocop-0.6.1 vs lib/rubocop/cop/brace_after_percent.rb in rubocop-0.7.0

- old
+ new

@@ -3,24 +3,28 @@ module Rubocop module Cop class BraceAfterPercent < Cop ERROR_MESSAGE = 'Prefer () as delimiters for all % literals.' LITERALS = { - on_tstring_beg: '%q', + on_tstring_beg: ['%q', '%Q'], on_words_beg: '%W', on_qwords_beg: '%w', + on_qsymbols_beg: '%i', + on_symbols_beg: '%I', on_regexp_beg: '%r', on_symbeg: '%s', on_backtick: '%x' } def inspect(file, source, tokens, sexp) tokens.each_index do |ix| t = tokens[ix] - token = LITERALS[t.type] - if token && t.text.downcase.start_with?(token) && t.text[2] != '(' - add_offence(:convention, t.pos.lineno, - ERROR_MESSAGE) + literals = Array(LITERALS[t.type]) + literals.each do |literal| + if literal && t.text.start_with?(literal) && t.text[2] != '(' + add_offence(:convention, t.pos.lineno, + ERROR_MESSAGE) + end end end end end end