class ERBLint::Linters::GitHub::Accessibility::NoRedundantImageAlt

Constants

MESSAGE
REDUNDANT_ALT_WORDS

Public Instance Methods

run(processed_source) click to toggle source
# File lib/erblint-github/linters/github/accessibility/no_redundant_image_alt.rb, line 16
def run(processed_source)
  tags(processed_source).each do |tag|
    next if tag.name != "img"
    next if tag.closing?

    alt = possible_attribute_values(tag, "alt").join
    next if alt.empty?

    generate_offense(self.class, processed_source, tag) if (alt.downcase.split & REDUNDANT_ALT_WORDS).any?
  end

  rule_disabled?(processed_source)
end