Sha256: 8a24872eb9d6f33733d89675a101d990a22e0bb8d43453f7e010188beaf3b298

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Rubocop
  module Cop
    module InternalAffairs
      # Cop that denies the use of CopHelper.
      class DeprecateCopHelper < RuboCop::Cop::Base
        MSG = 'Do not use `CopHelper` or methods from it, use improved patterns described in https://www.rubydoc.info/gems/rubocop/RuboCop/RSpec/ExpectOffense'

        # @!method cop_helper(node)
        def_node_matcher :cop_helper, <<~PATTERN
          (send nil? ${:include :extend :prepend}
            (const _ {:CopHelper}))
        PATTERN

        # @!method cop_helper_method(node)
        def_node_search :cop_helper_method, <<~PATTERN
          (send nil? {:inspect_source :inspect_source_file :parse_source :autocorrect_source_file :autocorrect_source :_investigate} ...)
        PATTERN

        # @!method cop_helper_method_on_instance(node)
        def_node_search :cop_helper_method_on_instance, <<~PATTERN
          (send (send nil? _) {:messages :highlights :offenses} ...)
        PATTERN

        def on_send(node)
          cop_helper(node) do
            add_offense(node)
          end

          cop_helper_method(node) do
            add_offense(node)
          end

          cop_helper_method_on_instance(node) do
            add_offense(node)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gitlab-styles-13.0.1 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-13.0.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-11.0.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-10.1.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-10.0.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-9.2.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-9.1.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-9.0.0 lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb