Class: RuboCop::Cop::Discourse::NoNokogiriHtmlFragment

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb

Overview

Do not use Nokogiri::HTML.fragment Instead use Nokogiri::HTML5.fragment, which is using Nokogumbo parser

Examples:

# bad
Nokogiri::HTML.fragment("<p>test</p>")

# good
Nokogiri::HTML5.fragment("<p>test</p>")

Constant Summary collapse

MSG =
"Nokogiri::HTML.fragment is deprecated and should not be used."

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



24
25
26
27
# File 'lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb', line 24

def on_send(node)
  return if !using_nokogiri_html_fragment?(node)
  add_offense(node, message: MSG)
end