Sha256: 88f215d6e9ce8ffd10fc95f2b8522ddc3e966b7bd9233ada88ade3423b5e428f
Contents?: true
Size: 915 Bytes
Versions: 4
Compression:
Stored size: 915 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class Semicolon < Cop MSG = 'Do not use semicolons to terminate expressions.' def inspect(source, tokens, ast, comments) on_node(:begin, ast) do |node| exprs = node.children next if exprs.size < 2 # create a map matching lines to the number of expressions on them exprs_lines = exprs.map { |e| e.loc.expression.line } lines = exprs_lines.group_by { |i| i } # every line with more than 1 expression on it is an offence lines.each do |line, expr_on_line| add_offence(:convention, line, MSG) if expr_on_line.size > 1 end end # not pretty reliable, but the best we can do for now source.each_with_index do |line, index| add_offence(:convention, index, MSG) if line =~ /;\s*\z/ end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/semicolon.rb |
rubocop-0.8.2 | lib/rubocop/cop/semicolon.rb |
rubocop-0.8.1 | lib/rubocop/cop/semicolon.rb |
rubocop-0.8.0 | lib/rubocop/cop/semicolon.rb |