class ERBLint::Linters::GitHub::Accessibility::NoTitleAttributeCounter
Constants
- MESSAGE
Public Instance Methods
autocorrect(processed_source, offense)
click to toggle source
# File lib/erblint-github/linters/github/accessibility/no_title_attribute_counter.rb, line 27 def autocorrect(processed_source, offense) return unless offense.context lambda do |corrector| if processed_source.file_content.include?("erblint:counter #{simple_class_name}") # update the counter if exists corrector.replace(offense.source_range, offense.context) else # add comment with counter if none corrector.insert_before(processed_source.source_buffer.source_range, "#{offense.context}\n") end end end
run(processed_source)
click to toggle source
# File lib/erblint-github/linters/github/accessibility/no_title_attribute_counter.rb, line 15 def run(processed_source) tags(processed_source).each do |tag| next if tag.name == "iframe" next if tag.closing? title = possible_attribute_values(tag, "title") generate_offense(self.class, processed_source, tag) if title.present? end counter_correct?(processed_source) end