Sha256: cec7c67e3f081a84be491720f8e7913c90fb24343ff27db4f27e6c8805eb8474

Contents?: true

Size: 651 Bytes

Versions: 16

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for END blocks.
      #
      # @example
      #   # bad
      #   END { puts 'Goodbye!' }
      #
      #   # good
      #   at_exit { puts 'Goodbye!' }
      #
      class EndBlock < Cop
        MSG = 'Avoid the use of `END` blocks. ' \
              'Use `Kernel#at_exit` instead.'

        def on_postexe(node)
          add_offense(node, location: :keyword)
        end

        def autocorrect(node)
          lambda do |corrector|
            corrector.replace(node.loc.keyword, 'at_exit')
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
rubocop-0.89.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.88.0 lib/rubocop/cop/style/end_block.rb
rbhint-0.87.1.rc1 lib/rubocop/cop/style/end_block.rb
rubocop-0.87.1 lib/rubocop/cop/style/end_block.rb
rubocop-0.87.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.86.0 lib/rubocop/cop/style/end_block.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/cop/style/end_block.rb
rbhint-0.85.1.rc2 lib/rubocop/cop/style/end_block.rb
rbhint-0.85.1.rc1 lib/rubocop/cop/style/end_block.rb
rubocop-0.85.1 lib/rubocop/cop/style/end_block.rb
rbhint-0.8.5.rc1 lib/rubocop/cop/style/end_block.rb
rubocop-0.85.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.84.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.83.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.82.0 lib/rubocop/cop/style/end_block.rb
rubocop-0.81.0 lib/rubocop/cop/style/end_block.rb