Sha256: 9d58b273ff01858051440f66f8768aaeac5b158a28da0522f239e5b5f041eaee

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Lint
      # @example
      #   # bad
      #   class Foo < Grape::API
      #
      #   # good
      #   class Foo < Api::AuthBase
      #
      #   # good
      #   class Foo < Api::Base
      class NoGrapeAPI < Cop
        MSG = "Prefer inheriting `Api::AuthBase` or `Api::Base` instead of `Grape::API`."

        def_node_matcher :inherits_Grape_API?, "(class (const ...) (const (const nil? :Grape) :API) ...)"

        def on_class(node)
          return unless inherits_Grape_API?(node)
          add_offense(node)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rf-stylez-1.0.3 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-1.0.2 lib/rubocop/cop/lint/no_grape_api.rb