Sha256: ea0d2a9b0c6c3187d2338455816d588675251edc99218391a6904d879a991020

Contents?: true

Size: 956 Bytes

Versions: 73

Compression:

Stored size: 956 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 < Base
        include Alignment
        include TrailingBody
        extend AutoCorrector

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

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

          add_offense(first_part_of(node.to_a.last)) 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

73 entries across 73 versions & 8 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/style/trailing_body_on_class.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.29.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.29.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.28.2 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.28.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.28.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.27.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.26.1 lib/rubocop/cop/style/trailing_body_on_class.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/rubocop-1.26.0/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.26.0 lib/rubocop/cop/style/trailing_body_on_class.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/cop/style/trailing_body_on_class.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.25.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.25.0 lib/rubocop/cop/style/trailing_body_on_class.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/style/trailing_body_on_class.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/cop/style/trailing_body_on_class.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/rubocop-1.24.0/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.24.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.24.0 lib/rubocop/cop/style/trailing_body_on_class.rb