Sha256: 8a52b2838f79380416eb1bab66131f7e646f2dd4f49f09c7b9aa189cf99dd161

Contents?: true

Size: 773 Bytes

Versions: 108

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require "rubocop"
require "primer/view_components/statuses"
require_relative "../../../../app/lib/primer/view_helper"

module RuboCop
  module Cop
    module Primer
      # :nodoc:
      class BaseCop < RuboCop::Cop::Cop
        # We only verify SystemArguments if it's a `.new` call on a component or
        # a ViewHeleper call.
        def valid_node?(node)
          return if node.nil?

          view_helpers.include?(node.method_name) || (node.method_name == :new && !node.receiver.nil? && ::Primer::ViewComponents::STATUSES.key?(node.receiver.const_name))
        end

        private

        def view_helpers
          ::Primer::ViewHelper::HELPERS.keys.map { |key| "primer_#{key}".to_sym }
        end
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 2 rubygems

Version Path
primer_view_components-0.0.62 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.61 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.60 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.59 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.58 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.57 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.56 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.0.55 lib/rubocop/cop/primer/base_cop.rb