Sha256: 8d653f2386551f68e9bff2e94d6b5ec54afa3dc6f944f56e58d430898b53a0e9

Contents?: true

Size: 1011 Bytes

Versions: 12

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RBS
      module Style
        # @example default
        #   # bad
        #   def foo: () { () -> bool } -> void
        #
        #   # good
        #   def foo: () { () -> boolish } -> void
        class BlockReturnBoolish < RuboCop::RBS::CopBase
          extend AutoCorrector
          MSG = 'Use `boolish` instead of `bool` in block return type.'

          # @sig decl: ::RBS::AST::Members::MethodDefinition
          def on_rbs_def(decl)
            decl.overloads.each do |overload|
              next unless overload.method_type.block

              return_type = overload.method_type.block.type.return_type
              next unless return_type.is_a?(::RBS::Types::Bases::Bool)

              range = location_to_range(return_type.location)
              add_offense(range) do |corrector|
                corrector.replace(range, 'boolish')
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-on-rbs-1.3.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-1.2.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-1.1.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-1.0.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.9.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.8.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.7.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.6.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.5.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.4.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.3.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb
rubocop-on-rbs-0.2.0 lib/rubocop/cop/rbs/style/block_return_boolish.rb