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-1.0.1 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-1.0.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.16.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.15.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.14.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.13.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.12.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.11.1 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.11.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.10.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.9.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.8.0 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.8.0.pre2 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.8.0.pre lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.2 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.2.pre2 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.2.pre lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.1 lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.1.pre lib/rubocop/cop/lint/no_grape_api.rb
rf-stylez-0.7.0 lib/rubocop/cop/lint/no_grape_api.rb