lib/rubocop/cop/surrounding_space.rb in rubocop-0.8.0 vs lib/rubocop/cop/surrounding_space.rb in rubocop-0.8.1
- old
+ new
@@ -244,11 +244,13 @@
def inspect(source, tokens, sexp, comments)
@source = source
on_node(:hash, sexp) do |hash|
b_ix = index_of_first_token(hash, tokens)
e_ix = index_of_last_token(hash, tokens)
- check(tokens[b_ix], tokens[b_ix + 1])
- check(tokens[e_ix - 1], tokens[e_ix])
+ if tokens[b_ix].type == :tLBRACE # Hash literal with braces?
+ check(tokens[b_ix], tokens[b_ix + 1])
+ check(tokens[e_ix - 1], tokens[e_ix])
+ end
end
end
def check(t1, t2)
types = [t1, t2].map(&:type)