Sha256: 61c948399c9957e9350549c2ea17442aa3cfba88ce4ebafc7e52fbad88a02d0a

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks the . position in multi-line method calls.
      class DotPosition < Cop
        MSG = 'Place the . on the next line, together with the method name.'

        def on_send(node)
          return unless node.loc.dot

          unless proper_dot_position?(node)
            add_offence(:convention, node.loc.dot, MSG)
          end
        end

        private

        def proper_dot_position?(node)
          dot_line = node.loc.dot.line
          selector_line = node.loc.selector.line

          case DotPosition.config['Style'].downcase
          when 'leading' then dot_line == selector_line
          when 'trailing' then dot_line != selector_line
          else fail 'Unknown dot position style selected.'
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.10.0 lib/rubocop/cop/style/dot_position.rb