Sha256: ed5541b96f7f467fa1dfc61b5c207d65b59f94d6948f8c6ab5ad01f158849f04

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks whether method definitions are
      # separated by empty lines.
      class EmptyLineBetweenDefs < Cop
        MSG = 'Use empty lines between defs.'

        def on_def(node)
          def_start = node.loc.keyword.line
          def_end = node.loc.end.line

          if @prev_def_end && (def_start - @prev_def_end) < 2
            add_offence(:convention, node.loc.keyword, MSG)
          end

          @prev_def_end = def_end

          super
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/empty_line_between_defs.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/empty_line_between_defs.rb
rubocop-0.9.0 lib/rubocop/cop/style/empty_line_between_defs.rb