Sha256: 18d7b0831c0644c2b113b1212bcf49b4ca023e504e3ef0d552758943a7c11a50

Contents?: true

Size: 638 Bytes

Versions: 35

Compression:

Stored size: 638 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`.'.freeze

        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

35 entries across 35 versions & 1 rubygems

Version Path
rf-stylez-0.6.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.5.1 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.5.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.4.1 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.4.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.3.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.23 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.22 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.21 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.20 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.19 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.18 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.17 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.16 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.2.15 lib/rubocop/cop/lint/no_grape_api.rb