in lib/primer/view_components/linters/base_linter.rb [35:79]
def run(processed_source)
@total_offenses = 0
@offenses_not_corrected = 0
(tags, tag_tree) = build_tag_tree(processed_source)
tags.each do |tag|
next if tag.closing?
next unless self.class::TAGS&.include?(tag.name)
classes = tag.attributes["class"]&.value&.split(" ") || []
tag_tree[tag][:offense] = false
next if (classes & self.class::DISALLOWED_CLASSES).any?
next unless self.class::CLASSES.blank? || (classes & self.class::CLASSES).any?
args = map_arguments(tag, tag_tree[tag])
correction = correction(args)
attributes = tag.attributes.each.map(&:name).join(" ")
matches_required_attributes = self.class::REQUIRED_ARGUMENTS.blank? || self.class::REQUIRED_ARGUMENTS.all? { |arg| attributes.match?(arg) }
tag_tree[tag][:offense] = true
tag_tree[tag][:correctable] = matches_required_attributes && !correction.nil?
tag_tree[tag][:message] = message(args, processed_source)
tag_tree[tag][:correction] = correction
end
tag_tree.each do |tag, h|
next unless h[:offense]
@total_offenses += 1
if h[:correctable]
add_correction(tag, h)
else
@offenses_not_corrected += 1
generate_offense(self.class, processed_source, tag, h[:message])
end
end
counter_correct?(processed_source)
dump_data(processed_source) if ENV["DUMP_LINT_DATA"] == "1"
end