Sha256: 8f1653faeba9c626a339e445c3cd6afa301ccf09986a343a330ed0b02817a280

Contents?: true

Size: 1002 Bytes

Versions: 62

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for trailing code after the class definition.
      #
      # @example
      #   # bad
      #   class Foo; def foo; end
      #   end
      #
      #   # good
      #   class Foo
      #     def foo; end
      #   end
      #
      class TrailingBodyOnClass < Cop
        include Alignment
        include TrailingBody

        MSG = 'Place the first line of class body on its own line.'

        def on_class(node)
          return unless trailing_body?(node)

          add_offense(node, location: first_part_of(node.to_a.last))
        end

        def autocorrect(node)
          lambda do |corrector|
            LineBreakCorrector.correct_trailing_body(
              configured_width: configured_indentation_width,
              corrector: corrector,
              node: node,
              processed_source: processed_source
            )
          end
        end
      end
    end
  end
end

Version data entries

62 entries across 43 versions & 5 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.89.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.89.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.88.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rbhint-0.87.1.rc1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.87.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.87.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.86.0 lib/rubocop/cop/style/trailing_body_on_class.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/style/trailing_body_on_class.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/style/trailing_body_on_class.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.85.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.85.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.84.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.83.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.82.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.81.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.80.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-0.80.0 lib/rubocop/cop/style/trailing_body_on_class.rb