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
primer_view_components-0.35.2 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.49.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.49.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.35.1 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.35.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.48.2 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.48.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.48.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.47.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.47.0 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.34.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.46.1 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.46.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.45.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.44.3 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.44.2 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.44.1 lib/rubocop/cop/primer/base_cop.rb
primer_view_components-0.33.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.44.0 lib/rubocop/cop/primer/base_cop.rb
openproject-primer_view_components-0.43.1 lib/rubocop/cop/primer/base_cop.rb