Sha256: 8e1992293a4b1fa2e5c7947ffcd61994784f3d66ce48e64c6bade5bf2b412967

Contents?: true

Size: 980 Bytes

Versions: 145

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # 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
        alias on_sclass on_class
      end
    end
  end
end

Version data entries

145 entries across 144 versions & 14 rubygems

Version Path
rubocop-1.68.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.67.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.66.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.66.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.65.1 lib/rubocop/cop/style/trailing_body_on_class.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.65.0 lib/rubocop/cop/style/trailing_body_on_class.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.64.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.63.4 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.63.3 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.63.2 lib/rubocop/cop/style/trailing_body_on_class.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.63.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.63.0 lib/rubocop/cop/style/trailing_body_on_class.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.62.1 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.62.0 lib/rubocop/cop/style/trailing_body_on_class.rb
rubocop-1.61.0 lib/rubocop/cop/style/trailing_body_on_class.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.2/lib/rubocop/cop/style/trailing_body_on_class.rb