Sha256: b96f8869bb2816764bc011f314bb36938f96ddb3ea580307ad5bc1d79f601d77

Contents?: true

Size: 1.1 KB

Versions: 6777

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for pipes for empty block parameters. Pipes for empty
      # block parameters do not cause syntax errors, but they are redundant.
      #
      # @example
      #   # bad
      #   a do ||
      #     do_something
      #   end
      #
      #   # bad
      #   a { || do_something }
      #
      #   # good
      #   a do
      #   end
      #
      #   # good
      #   a { do_something }
      class EmptyBlockParameter < Cop
        include EmptyParameter
        include RangeHelp

        MSG = 'Omit pipes for the empty block parameters.'.freeze

        def on_block(node)
          send_node = node.send_node
          check(node) unless send_node.send_type? && send_node.lambda_literal?
        end

        def autocorrect(node)
          lambda do |corrector|
            block = node.parent
            range = range_between(
              block.loc.begin.end_pos,
              node.loc.expression.end_pos
            )
            corrector.remove(range)
          end
        end
      end
    end
  end
end

Version data entries

6,777 entries across 6,771 versions & 24 rubygems

Version Path
cybrid_api_organization_ruby-0.123.118 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb
cybrid_api_id_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/empty_block_parameter.rb