Sha256: 483954a7ced3af997cf1ab29475afaa9c28e125e87d6c361c3b6c8d54cbd4cc8

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for redundant `begin` blocks.
      #
      # Currently it checks for code like this:
      #
      # @example
      #
      #   def test
      #     begin
      #       ala
      #       bala
      #     rescue StandardError => e
      #       something
      #     end
      #   end
      class RedundantBegin < Cop
        include CheckMethods

        MSG = 'Redundant `begin` block detected.'

        private

        def check(_node, _method_name, _args, body)
          return unless body && body.type == :kwbegin

          add_offense(body, :begin)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.20.1 lib/rubocop/cop/style/redundant_begin.rb
rubocop-0.20.0 lib/rubocop/cop/style/redundant_begin.rb
rubocop-0.19.1 lib/rubocop/cop/style/redundant_begin.rb
rubocop-0.19.0 lib/rubocop/cop/style/redundant_begin.rb