Sha256: f94858c6255b8ec4b12ba8f5e470867525cc96c84e095b67dad7a8b289a0b9bb

Contents?: true

Size: 779 Bytes

Versions: 86

Compression:

Stored size: 779 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 false 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

86 entries across 86 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.43.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.32.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.42.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.31.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.41.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.41.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.40.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.30.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.39.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.39.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.38.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.29.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.28.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.37.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.37.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.36.2 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.36.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.36.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.27.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.35.2 lib/rubocop/cop/primer/base_cop.rb