Sha256: 01dd88bd4c0c6810f55f9fc1a455db95d72ff312d4f1f4f08bee06fa7d88370a
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Sorbet # Checks for the use of Ruby Refinements library. Refinements add # complexity and incur a performance penalty that can be significant # for large code bases. Good examples are cases of unrelated # methods that happen to have the same name as these module methods. # # @example # # bad # module Foo # refine(Date) do # end # end # # # bad # module Foo # using(Date) do # end # end # # # good # module Foo # bar.refine(Date) # end # # # good # module Foo # bar.using(Date) # end class Refinement < Base MSG = "Do not use Ruby Refinements library as it is not supported by Sorbet." RESTRICT_ON_SEND = [:refine, :using].freeze def on_send(node) return unless node.receiver.nil? return unless node.first_argument&.const_type? if node.method?(:refine) return unless node.block_node return unless node.parent.parent.module_type? end add_offense(node) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-sorbet-0.8.7 | lib/rubocop/cop/sorbet/refinement.rb |
rubocop-sorbet-0.8.6 | lib/rubocop/cop/sorbet/refinement.rb |