Sha256: c46ac9ba7b64826564e79526295bd81e01320f2cec6ee35e5d5b326dba190912

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

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

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

            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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gitlab-styles-7.1.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-7.0.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.6.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.5.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.4.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.3.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.2.1 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.2.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.1.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
gitlab-styles-6.0.0 lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb