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
openproject-primer_view_components-0.16.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.15.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.14.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.13.1 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.13.2 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.13.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.13.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.13.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.12.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.11.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.12.1 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.10.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.11.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.10.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.9.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.9.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.9.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.8.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.8.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.7.0 lib/rubocop/cop/primer/base_cop.rb