From fe31189f82e71232dbf26d8ee6c0c3245dac42cc Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Nov 2023 20:59:02 -0500 Subject: [PATCH 1/5] remove Nokogiri::HTML5.get which was deprecated in v1.12.0 --- CHANGELOG.md | 4 +++ lib/nokogiri/html5.rb | 66 ------------------------------------------- 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc4c0df984..1bf1c47e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,10 @@ Documentation on what can be matched: * CSS `nth` pseudo-classes now handle spaces, e.g. `"2n + 1"`. [#3018] (@fusion2004) * `libgumbo` no longer leaks memory when an incomplete tag is abandoned by the HTML5 parser. [#3036] (@flavorjones) +### Removed + +* Removed `Nokogiri::HTML5.get` which was deprecated in v1.12.0. [#2278] (@flavorjones) + ## 1.15.5 / 2023-11-17 diff --git a/lib/nokogiri/html5.rb b/lib/nokogiri/html5.rb index 32dd593759..7e981f4bc2 100644 --- a/lib/nokogiri/html5.rb +++ b/lib/nokogiri/html5.rb @@ -239,23 +239,6 @@ def fragment(string, encoding = nil, **options) DocumentFragment.parse(string, encoding, options) end - # Fetch and parse a HTML document from the web, following redirects, - # handling https, and determining the character encoding using HTML5 - # rules. +uri+ may be a +String+ or a +URI+. +options+ contains - # http headers and special options. Everything which is not a - # special option is considered a header. Special options include: - # * :follow_limit => number of redirects which are followed - # * :basic_auth => [username, password] - def get(uri, options = {}) - # TODO: deprecate - warn( - "Nokogiri::HTML5.get is deprecated and will be removed in a future version of Nokogiri.", - uplevel: 1, - category: :deprecated, - ) - get_impl(uri, options) - end - # :nodoc: def read_and_encode(string, encoding) # Read the string with the given encoding. @@ -283,55 +266,6 @@ def read_and_encode(string, encoding) private - def get_impl(uri, options = {}) - headers = options.clone - headers = { follow_limit: headers } if Numeric === headers # deprecated - limit = headers[:follow_limit] ? headers.delete(:follow_limit).to_i : 10 - - require "net/http" - uri = URI(uri) unless URI === uri - - http = Net::HTTP.new(uri.host, uri.port) - - # TLS / SSL support - http.use_ssl = true if uri.scheme == "https" - - # Pass through Net::HTTP override values, which currently include: - # :ca_file, :ca_path, :cert, :cert_store, :ciphers, - # :close_on_empty_response, :continue_timeout, :key, :open_timeout, - # :read_timeout, :ssl_timeout, :ssl_version, :use_ssl, - # :verify_callback, :verify_depth, :verify_mode - options.each do |key, _value| - http.send("#{key}=", headers.delete(key)) if http.respond_to?("#{key}=") - end - - request = Net::HTTP::Get.new(uri.request_uri) - - # basic authentication - auth = headers.delete(:basic_auth) - auth ||= [uri.user, uri.password] if uri.user && uri.password - request.basic_auth(auth.first, auth.last) if auth - - # remaining options are treated as headers - headers.each { |key, value| request[key.to_s] = value.to_s } - - response = http.request(request) - - case response - when Net::HTTPSuccess - doc = parse(reencode(response.body, response["content-type"]), options) - doc.instance_variable_set(:@response, response) - doc.class.send(:attr_reader, :response) - doc - when Net::HTTPRedirection - response.value if limit <= 1 - location = URI.join(uri, response["location"]) - get_impl(location, options.merge(follow_limit: limit - 1)) - else - response.value - end - end - # Charset sniffing is a complex and controversial topic that understandably isn't done _by # default_ by the Ruby Net::HTTP library. This being said, it is a very real problem for # consumers of HTML as the default for HTML is iso-8859-1, most "good" producers use utf-8, and From cf0c55e9164857262dd9ecc261235999d329314d Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Nov 2023 21:03:57 -0500 Subject: [PATCH 2/5] remove css-to-xpath convenience classes deprecated in v1.13.0 - XPathVisitorAlwaysUseBuiltins - XPathVisitorOptimallyUseBuiltins --- CHANGELOG.md | 1 + lib/nokogiri/css/xpath_visitor.rb | 20 ----------------- test/css/test_xpath_visitor.rb | 37 ------------------------------- 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf1c47e97..734f1428b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Documentation on what can be matched: ### Removed * Removed `Nokogiri::HTML5.get` which was deprecated in v1.12.0. [#2278] (@flavorjones) +* Removed the CSS-to-XPath utility modules `XPathVisitorAlwaysUseBuiltins` and `XPathVisitorOptimallyUseBuiltins`, which were deprecated in v1.13.0 in favor of `XPathVisitor` constructor args. [#2403] (@flavorjones) ## 1.15.5 / 2023-11-17 diff --git a/lib/nokogiri/css/xpath_visitor.rb b/lib/nokogiri/css/xpath_visitor.rb index 6d8ab67ce6..44521f2fbe 100644 --- a/lib/nokogiri/css/xpath_visitor.rb +++ b/lib/nokogiri/css/xpath_visitor.rb @@ -335,25 +335,5 @@ def css_class(hay, needle) end end end - - module XPathVisitorAlwaysUseBuiltins # :nodoc: - def self.new - warn( - "Nokogiri::CSS::XPathVisitorAlwaysUseBuiltins is deprecated and will be removed in a future version of Nokogiri", - { uplevel: 1 }, - ) - XPathVisitor.new(builtins: :always) - end - end - - module XPathVisitorOptimallyUseBuiltins # :nodoc: - def self.new - warn( - "Nokogiri::CSS::XPathVisitorOptimallyUseBuiltins is deprecated and will be removed in a future version of Nokogiri", - { uplevel: 1 }, - ) - XPathVisitor.new(builtins: :optimal) - end - end end end diff --git a/test/css/test_xpath_visitor.rb b/test/css/test_xpath_visitor.rb index 5a5be68e13..dec81369c4 100644 --- a/test/css/test_xpath_visitor.rb +++ b/test/css/test_xpath_visitor.rb @@ -567,21 +567,6 @@ def visit_pseudo_class_aaron(node) parser.parse("a[@data-words~=\"bar\"]"), ) end - - describe "XPathVisitorAlwaysUseBuiltins" do - let(:visitor) { Nokogiri::CSS::XPathVisitorAlwaysUseBuiltins.new } - - it "supports deprecated class" do - assert_output("", /XPathVisitorAlwaysUseBuiltins is deprecated/) { visitor } - assert_instance_of(Nokogiri::CSS::XPathVisitor, visitor) - assert_equal({ builtins: Nokogiri::CSS::XPathVisitor::BuiltinsConfig::ALWAYS, doctype: Nokogiri::CSS::XPathVisitor::DoctypeConfig::XML }, visitor.config) - - assert_xpath( - "//*[nokogiri-builtin:css-class(@class,'awesome')]", - parser.parse(".awesome"), - ) - end - end end describe "builtins:optimal" do @@ -658,28 +643,6 @@ def visit_pseudo_class_aaron(node) ) end end - - describe "XPathVisitorOptimallyUseBuiltins" do - let(:visitor) { Nokogiri::CSS::XPathVisitorOptimallyUseBuiltins.new } - - it "supports deprecated class" do - assert_output("", /XPathVisitorOptimallyUseBuiltins is deprecated/) { visitor } - assert_instance_of(Nokogiri::CSS::XPathVisitor, visitor) - assert_equal({ builtins: Nokogiri::CSS::XPathVisitor::BuiltinsConfig::OPTIMAL, doctype: Nokogiri::CSS::XPathVisitor::DoctypeConfig::XML }, visitor.config) - - if Nokogiri.uses_libxml? - assert_xpath( - "//*[nokogiri-builtin:css-class(@class,'awesome')]", - parser.parse(".awesome"), - ) - else - assert_xpath( - "//*[contains(concat(' ',normalize-space(@class),' '),' awesome ')]", - parser.parse(".awesome"), - ) - end - end - end end # From fd84050bba41aa5d1ff50fa9865cbcb97ee8a6f1 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Nov 2023 21:23:37 -0500 Subject: [PATCH 3/5] doc: update deprecation warnings with a specific version of nokogiri and add comments with deprecation and removal plan to make it easy later on. --- ext/java/nokogiri/XmlCdata.java | 3 +-- ext/java/nokogiri/XmlNode.java | 3 +-- ext/java/nokogiri/XmlSchema.java | 3 +-- ext/java/nokogiri/XmlText.java | 3 +-- ext/nokogiri/xml_cdata.c | 3 +-- ext/nokogiri/xml_node.c | 3 +-- ext/nokogiri/xml_schema.c | 3 +-- ext/nokogiri/xml_text.c | 3 +-- ext/nokogiri/xml_xpath_context.c | 7 ++----- lib/nokogiri.rb | 2 +- 10 files changed, 11 insertions(+), 22 deletions(-) diff --git a/ext/java/nokogiri/XmlCdata.java b/ext/java/nokogiri/XmlCdata.java index e8eee55fc2..423984ba5f 100644 --- a/ext/java/nokogiri/XmlCdata.java +++ b/ext/java/nokogiri/XmlCdata.java @@ -51,8 +51,7 @@ public class XmlCdata extends XmlText throw context.runtime.newTypeError(msg); } if (!(rbDocument instanceof XmlDocument)) { - // TODO: deprecate allowing Node - context.runtime.getWarnings().warn("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + context.runtime.getWarnings().warn("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 } Document document = ((XmlNode) rbDocument).getOwnerDocument(); diff --git a/ext/java/nokogiri/XmlNode.java b/ext/java/nokogiri/XmlNode.java index 4cca197a70..520f1aa7d5 100644 --- a/ext/java/nokogiri/XmlNode.java +++ b/ext/java/nokogiri/XmlNode.java @@ -311,8 +311,7 @@ public class XmlNode extends RubyObject throw context.runtime.newArgumentError("document must be a Nokogiri::XML::Node"); } if (!(doc instanceof XmlDocument)) { - // TODO: deprecate allowing Node - context.runtime.getWarnings().warn("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri."); + context.runtime.getWarnings().warn("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.13.0, remove in v1.17.0 } Document document = asXmlNode(context, doc).getOwnerDocument(); diff --git a/ext/java/nokogiri/XmlSchema.java b/ext/java/nokogiri/XmlSchema.java index bc5dd29c06..0fbb7ad2dd 100644 --- a/ext/java/nokogiri/XmlSchema.java +++ b/ext/java/nokogiri/XmlSchema.java @@ -154,8 +154,7 @@ public class XmlSchema extends RubyObject throw context.runtime.newTypeError(msg); } if (!(rbDocument instanceof XmlDocument)) { - // TODO: deprecate allowing Node - context.runtime.getWarnings().warn("Passing a Node as the first parameter to Schema.from_document is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + context.runtime.getWarnings().warn("Passing a Node as the first parameter to Schema.from_document is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 } XmlDocument doc = ((XmlDocument)((XmlNode) rbDocument).document(context)); diff --git a/ext/java/nokogiri/XmlText.java b/ext/java/nokogiri/XmlText.java index 47dda1d178..f51bc6b91c 100644 --- a/ext/java/nokogiri/XmlText.java +++ b/ext/java/nokogiri/XmlText.java @@ -58,8 +58,7 @@ public class XmlText extends XmlNode throw context.runtime.newTypeError(msg); } if (!(rbDocument instanceof XmlDocument)) { - // TODO: deprecate allowing Node - context.runtime.getWarnings().warn("Passing a Node as the second parameter to Text.new is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + context.runtime.getWarnings().warn("Passing a Node as the second parameter to Text.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 } Document document = asXmlNode(context, rbDocument).getOwnerDocument(); diff --git a/ext/nokogiri/xml_cdata.c b/ext/nokogiri/xml_cdata.c index eb7ac59e5c..cb04cadc3d 100644 --- a/ext/nokogiri/xml_cdata.c +++ b/ext/nokogiri/xml_cdata.c @@ -33,8 +33,7 @@ rb_xml_cdata_s_new(int argc, VALUE *argv, VALUE klass) if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) { xmlNodePtr deprecated_node_type_arg; - // TODO: deprecate allowing Node - NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to CDATA.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 Noko_Node_Get_Struct(rb_document, xmlNode, deprecated_node_type_arg); c_document = deprecated_node_type_arg->doc; } else { diff --git a/ext/nokogiri/xml_node.c b/ext/nokogiri/xml_node.c index 174c831957..32c17f031b 100644 --- a/ext/nokogiri/xml_node.c +++ b/ext/nokogiri/xml_node.c @@ -2058,8 +2058,7 @@ rb_xml_node_new(int argc, VALUE *argv, VALUE klass) rb_raise(rb_eArgError, "document must be a Nokogiri::XML::Node"); } if (!rb_obj_is_kind_of(rb_document_node, cNokogiriXmlDocument)) { - // TODO: deprecate allowing Node - NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri."); + NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.13.0, remove in v1.17.0 } Noko_Node_Get_Struct(rb_document_node, xmlNode, c_document_node); diff --git a/ext/nokogiri/xml_schema.c b/ext/nokogiri/xml_schema.c index 3540d7496d..5bd24ab31f 100644 --- a/ext/nokogiri/xml_schema.c +++ b/ext/nokogiri/xml_schema.c @@ -222,8 +222,7 @@ rb_xml_schema_s_from_document(int argc, VALUE *argv, VALUE klass) if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) { xmlNodePtr deprecated_node_type_arg; - // TODO: deprecate allowing Node - NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to Schema.from_document is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + NOKO_WARN_DEPRECATION("Passing a Node as the first parameter to Schema.from_document is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 Noko_Node_Get_Struct(rb_document, xmlNode, deprecated_node_type_arg); c_document = deprecated_node_type_arg->doc; } else { diff --git a/ext/nokogiri/xml_text.c b/ext/nokogiri/xml_text.c index bcdb6d44f6..3110201b47 100644 --- a/ext/nokogiri/xml_text.c +++ b/ext/nokogiri/xml_text.c @@ -28,8 +28,7 @@ rb_xml_text_s_new(int argc, VALUE *argv, VALUE klass) if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) { xmlNodePtr deprecated_node_type_arg; - // TODO: deprecate allowing Node - NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Text.new is deprecated. Please pass a Document instead. This will become an error in a future release of Nokogiri."); + NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Text.new is deprecated. Please pass a Document instead. This will become an error in Nokogiri v1.17.0."); // TODO: deprecated in v1.15.3, remove in v1.17.0 Noko_Node_Get_Struct(rb_document, xmlNode, deprecated_node_type_arg); c_document = deprecated_node_type_arg->doc; } else { diff --git a/ext/nokogiri/xml_xpath_context.c b/ext/nokogiri/xml_xpath_context.c index 175f5a2e26..23528ca7ed 100644 --- a/ext/nokogiri/xml_xpath_context.c +++ b/ext/nokogiri/xml_xpath_context.c @@ -321,11 +321,8 @@ handler_lookup(void *data, const xmlChar *c_name, const xmlChar *c_ns_uri) VALUE rb_handler = (VALUE)data; if (rb_respond_to(rb_handler, rb_intern((const char *)c_name))) { if (c_ns_uri == NULL) { - NOKO_WARN_DEPRECATION( - "A custom XPath or CSS handler function named '%s' is being invoked without a namespace." - " Please update your query to reference this function as 'nokogiri:%s'." - " Invoking custom handler functions without a namespace is deprecated and support will be removed in a future release of Nokogiri.", - c_name, c_name); + NOKO_WARN_DEPRECATION("A custom XPath or CSS handler function named '%s' is being invoked without a namespace. Please update your query to reference this function as 'nokogiri:%s'. Invoking custom handler functions without a namespace is deprecated and will become an error in Nokogiri v1.17.0.", + c_name, c_name); // deprecated in v1.15.0, remove in v1.17.0 } return method_caller; } diff --git a/lib/nokogiri.rb b/lib/nokogiri.rb index 7e31b4fdea..988b2918cd 100644 --- a/lib/nokogiri.rb +++ b/lib/nokogiri.rb @@ -94,7 +94,7 @@ def Slop(*args, &block) # :nodoc: def install_default_aliases - warn("Nokogiri.install_default_aliases is deprecated and will be removed in a future version of Nokogiri. Please call Nokogiri::EncodingHandler.install_default_aliases instead.") + warn("Nokogiri.install_default_aliases is deprecated. Please call Nokogiri::EncodingHandler.install_default_aliases instead. This will become an error in Nokogiri v1.17.0.", uplevel: 1, category: :deprecated) # deprecated in v1.14.0, remove in v1.17.0 Nokogiri::EncodingHandler.install_default_aliases end end From 9ece952eb1835072fdcd64fda40a7fe1c7773ec5 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 27 Nov 2023 21:45:24 -0500 Subject: [PATCH 4/5] remove XML::Reader#attribute_nodes which was deprecated in v1.13.8 --- CHANGELOG.md | 1 + ext/java/nokogiri/XmlReader.java | 8 ------ ext/nokogiri/xml_reader.c | 43 ---------------------------- test/xml/test_reader.rb | 49 -------------------------------- 4 files changed, 1 insertion(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 734f1428b1..a6f05f6d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Documentation on what can be matched: * Removed `Nokogiri::HTML5.get` which was deprecated in v1.12.0. [#2278] (@flavorjones) * Removed the CSS-to-XPath utility modules `XPathVisitorAlwaysUseBuiltins` and `XPathVisitorOptimallyUseBuiltins`, which were deprecated in v1.13.0 in favor of `XPathVisitor` constructor args. [#2403] (@flavorjones) +* Removed `XML::Reader#attribute_nodes` which was deprecated in v1.13.8 in favor of `#attribute_hash`. [#2598, #2599] (@flavorjones) ## 1.15.5 / 2023-11-17 diff --git a/ext/java/nokogiri/XmlReader.java b/ext/java/nokogiri/XmlReader.java index 403b5e7d4c..74ef72d631 100644 --- a/ext/java/nokogiri/XmlReader.java +++ b/ext/java/nokogiri/XmlReader.java @@ -138,14 +138,6 @@ public class XmlReader extends RubyObject return currentNode().getAttributeCount(); } - @JRubyMethod - public IRubyObject - attribute_nodes(ThreadContext context) - { - context.runtime.getWarnings().warn("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead."); - return currentNode().getAttributesNodes(); - } - @JRubyMethod public IRubyObject attribute_hash(ThreadContext context) diff --git a/ext/nokogiri/xml_reader.c b/ext/nokogiri/xml_reader.c index 3c78d50c87..7ea5976488 100644 --- a/ext/nokogiri/xml_reader.c +++ b/ext/nokogiri/xml_reader.c @@ -166,48 +166,6 @@ rb_xml_reader_namespaces(VALUE rb_reader) return rb_namespaces ; } -/* - :call-seq: attribute_nodes() → Array - - Get the attributes of the current node as an Array of XML:Attr - - ⚠ This method is deprecated and unsafe to use. It will be removed in a future version of Nokogiri. - - See related: #attribute_hash, #attributes - */ -static VALUE -rb_xml_reader_attribute_nodes(VALUE rb_reader) -{ - xmlTextReaderPtr c_reader; - xmlNodePtr c_node; - VALUE attr_nodes; - int j; - - // TODO: deprecated, remove in Nokogiri v1.15, see https://github.com/sparklemotion/nokogiri/issues/2598 - // After removal, we can also remove all the "node_has_a_document" special handling from xml_node.c - NOKO_WARN_DEPRECATION("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead."); - - TypedData_Get_Struct(rb_reader, xmlTextReader, &xml_reader_type, c_reader); - - if (! has_attributes(c_reader)) { - return rb_ary_new() ; - } - - c_node = xmlTextReaderExpand(c_reader); - if (c_node == NULL) { - return Qnil; - } - - attr_nodes = noko_xml_node_attrs(c_node); - - /* ensure that the Reader won't be GCed as long as a node is referenced */ - for (j = 0 ; j < RARRAY_LEN(attr_nodes) ; j++) { - rb_iv_set(rb_ary_entry(attr_nodes, j), "@reader", rb_reader); - } - - return attr_nodes; -} - /* :call-seq: attribute_hash() → Hash @@ -778,7 +736,6 @@ noko_init_xml_reader(void) rb_define_method(cNokogiriXmlReader, "attribute", reader_attribute, 1); rb_define_method(cNokogiriXmlReader, "attribute_at", attribute_at, 1); rb_define_method(cNokogiriXmlReader, "attribute_count", attribute_count, 0); - rb_define_method(cNokogiriXmlReader, "attribute_nodes", rb_xml_reader_attribute_nodes, 0); rb_define_method(cNokogiriXmlReader, "attribute_hash", rb_xml_reader_attribute_hash, 0); rb_define_method(cNokogiriXmlReader, "attributes?", attributes_eh, 0); rb_define_method(cNokogiriXmlReader, "base_uri", rb_xml_reader_base_uri, 0); diff --git a/test/xml/test_reader.rb b/test/xml/test_reader.rb index e5f01d32ec..1b34772853 100644 --- a/test/xml/test_reader.rb +++ b/test/xml/test_reader.rb @@ -504,55 +504,6 @@ def test_ns_uri ) end - def test_reader_node_attributes_keep_a_reference_to_the_reader - skip_unless_libxml2("valgrind tests should only run with libxml2") - - attribute_nodes = [] - - refute_valgrind_errors do - xml = <<~EOF - - - - EOF - - reader = Nokogiri::XML::Reader.from_memory(xml) - reader.each do |element| - assert_output(nil, /Reader#attribute_nodes is deprecated/) do - attribute_nodes += element.attribute_nodes - end - end - end - - assert_operator(attribute_nodes.length, :>, 0) - attribute_nodes.inspect - end - - def test_namespaced_attributes - reader = Nokogiri::XML::Reader.from_memory(<<-eoxml) - - hello - - - eoxml - attr_ns = [] - while reader.read - next unless reader.node_type == Nokogiri::XML::Node::ELEMENT_NODE - - assert_output(nil, /Reader#attribute_nodes is deprecated/) do - reader.attribute_nodes.each { |attr| attr_ns << (attr.namespace.nil? ? nil : attr.namespace.prefix) } - end - end - assert_equal( - [ - "commons", - "edi", - nil, - ], - attr_ns, - ) - end - def test_local_name reader = Nokogiri::XML::Reader.from_memory(<<-eoxml) From 819b41ee9ade9e803e1106c56f4eda44a134c146 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 28 Nov 2023 08:37:24 -0500 Subject: [PATCH 5/5] dev: update rubocop todo file --- .rubocop_todo.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 840f54f28f..2008828324 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,24 +1,17 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 50` -# on 2023-06-26 20:38:41 UTC using RuboCop version 1.53.1. +# on 2023-11-28 13:36:03 UTC using RuboCop version 1.57.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Lint/MixedCaseRange: - Exclude: - - 'test/test_compaction.rb' - -# Offense count: 22 +# Offense count: 20 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: def_self, self_class Style/ClassMethodsDefinitions: Exclude: - - 'lib/nokogiri/css/xpath_visitor.rb' - 'lib/nokogiri/html4/document_fragment.rb' - 'lib/nokogiri/html4/encoding_reader.rb' - 'lib/nokogiri/html4/sax/parser_context.rb' @@ -41,9 +34,9 @@ Style/MissingRespondToMissing: Exclude: - 'lib/nokogiri/xml/builder.rb' -# Offense count: 70 +# Offense count: 68 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: - Max: 250 + Max: 257