Sha256: 6209d85530f7cfdf158c2f67f4153206fce125098809f3ca1d1025abcc20be33
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module RuboCop module Cop module Style class GrepImplementation < Base extend RuboCop::Cop::AutoCorrector ERROR_MSG = "#grep and grep_v cannot be implemented" def_node_matcher :enumerable_grep_spec, <<~PATTERN (block (send nil? :describe (str "Enumerable#grep")) ...) PATTERN def_node_matcher :enumerable_grep_v_spec, <<~PATTERN (block (send nil? :describe (str "Enumerable#grep_v")) ...) PATTERN def_node_matcher :grep_spec_already_skipped, <<~PATTERN (block (send nil? :ruby_bug ...) ...) PATTERN def on_block(node) return if grep_spec_already_skipped(node.parent) return unless (expression = enumerable_grep_spec(node) || enumerable_grep_v_spec(node)) add_offense(node, message: ERROR_MSG) do |corrector| corrector.replace node, <<~RUBY ruby_bug '#11808', ''...'#{cop_config['GrepSupportRubyVersion']}' do #{node.source} end RUBY end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grizzly-rb-1.1.0 | conversion/lib/cops/grep_implementation.rb |
grizzly-rb-1.0.0 | conversion/lib/cops/grep_implementation.rb |