Sha256: 741c4dd6bbbb908074bbc69cb1791a4cd8fc5eb1643cae39f38ba680f40af08b

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Lint
      # This cop checks for *return* from an *ensure* block.
      class EnsureReturn < Cop
        MSG = 'Never return from an ensure block.'

        def on_ensure(node)
          _body, ensure_body = *node

          on_node(:return, ensure_body) do |e|
            add_offence(:warning, e.loc.expression, MSG)
          end

          super
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
sabat-rubocop-0.9.0 lib/rubocop/cop/lint/ensure_return.rb
rubocop-0.9.0 lib/rubocop/cop/lint/ensure_return.rb