Skip to content

Commit 54128f9

Browse files
committed
style(rubocop): newline after guard clause
Rubocop 2.5.0
1 parent 01f7a78 commit 54128f9

26 files changed

Lines changed: 59 additions & 0 deletions

ext/nokogiri/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ def iconv_configure_flags
382382
["iconv", "opt"].each do |target|
383383
config = preserving_globals { dir_config(target) }
384384
next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
385+
385386
idirs, ldirs = config.map do |dirs|
386387
Array(dirs).flat_map do |dir|
387388
dir.split(File::PATH_SEPARATOR)

lib/nokogiri/css/parser_extras.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ def set_cache(value) # rubocop:disable Naming/AccessorMethodName
2424
# Get the css selector in +string+ from the cache
2525
def [](string)
2626
return nil unless cache_on?
27+
2728
@mutex.synchronize { @cache[string] }
2829
end
2930

3031
# Set the css selector in +string+ in the cache to +value+
3132
def []=(string, value)
3233
return value unless cache_on?
34+
3335
@mutex.synchronize { @cache[string] = value }
3436
end
3537

lib/nokogiri/html4/document.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def initialize
241241

242242
def start_element(name, attrs = [])
243243
return unless name == "meta"
244+
244245
attr = Hash[attrs]
245246
(charset = attr["charset"]) &&
246247
(@encoding = charset)

lib/nokogiri/html4/sax/parser.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Parser < Nokogiri::XML::SAX::Parser
3030
def parse_memory(data, encoding = "UTF-8")
3131
raise ArgumentError unless data
3232
return if data.empty?
33+
3334
ctx = ParserContext.memory(data, encoding)
3435
yield ctx if block_given?
3536
ctx.parse_with(self)
@@ -51,6 +52,7 @@ def parse_file(filename, encoding = "UTF-8")
5152
raise ArgumentError unless filename
5253
raise Errno::ENOENT unless File.exist?(filename)
5354
raise Errno::EISDIR if File.directory?(filename)
55+
5456
ctx = ParserContext.file(filename, encoding)
5557
yield ctx if block_given?
5658
ctx.parse_with(self)

lib/nokogiri/html5.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ def serialize_node_internal(current_node, io, encoding, options)
361361
# :nodoc:
362362
def prepend_newline?(node)
363363
return false unless ["pre", "textarea", "listing"].include?(node.name) && !node.children.empty?
364+
364365
first_child = node.children[0]
365366
first_child.text? && first_child.content.start_with?("\n")
366367
end

lib/nokogiri/html5/document.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,19 @@ def parse(string_or_io, url = nil, encoding = nil, **options, &block)
4040
unless string_or_io.respond_to?(:read) || string_or_io.respond_to?(:to_str)
4141
raise ArgumentError, "not a string or IO object"
4242
end
43+
4344
do_parse(string_or_io, url, encoding, options)
4445
end
4546

4647
def read_io(io, url = nil, encoding = nil, **options)
4748
raise ArgumentError, "io object doesn't respond to :read" unless io.respond_to?(:read)
49+
4850
do_parse(io, url, encoding, options)
4951
end
5052

5153
def read_memory(string, url = nil, encoding = nil, **options)
5254
raise ArgumentError, "string object doesn't respond to :to_str" unless string.respond_to?(:to_str)
55+
5356
do_parse(string, url, encoding, options)
5457
end
5558

lib/nokogiri/html5/node.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ module HTML5
2727
module Node
2828
def inner_html(options = {})
2929
return super(options) unless document.is_a?(HTML5::Document)
30+
3031
result = options[:preserve_newline] && HTML5.prepend_newline?(self) ? +"\n" : +""
3132
result << children.map { |child| child.to_html(options) }.join
3233
result
3334
end
3435

3536
def write_to(io, *options)
3637
return super(io, *options) unless document.is_a?(HTML5::Document)
38+
3739
options = options.first.is_a?(Hash) ? options.shift : {}
3840
encoding = options[:encoding] || options[0]
3941
if Nokogiri.jruby?
@@ -64,6 +66,7 @@ def write_to(io, *options)
6466

6567
def fragment(tags)
6668
return super(tags) unless document.is_a?(HTML5::Document)
69+
6770
DocumentFragment.new(document, tags, self)
6871
end
6972

@@ -76,6 +79,7 @@ def fragment(tags)
7679
# actually create the xml namespace if it doesn't exist already.
7780
def add_child_node_and_reparent_attrs(node)
7881
return super(node) unless document.is_a?(HTML5::Document)
82+
7983
# I'm not sure what this method is supposed to do. Reparenting
8084
# namespaces is handled by libxml2, including child namespaces which
8185
# this method wouldn't handle.

lib/nokogiri/version/info.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def to_markdown
193193
def self.uses_libxml?(requirement = nil)
194194
return false unless VersionInfo.instance.libxml2?
195195
return true unless requirement
196+
196197
Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
197198
end
198199

lib/nokogiri/xml.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def Reader(string_or_io, url = nil, encoding = nil, options = ParseOptions::STRI
2727
if string_or_io.respond_to?(:read)
2828
return Reader.from_io(string_or_io, url, encoding, options.to_i)
2929
end
30+
3031
Reader.from_memory(string_or_io, url, encoding, options.to_i)
3132
end
3233

lib/nokogiri/xml/builder.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def [](ns)
363363

364364
@parent.ancestors.each do |a|
365365
next if a == doc
366+
366367
@ns = a.namespace_definitions.find { |x| x.prefix == ns.to_s }
367368
return self if @ns
368369
end
@@ -407,6 +408,7 @@ def method_missing(method, *args, &block) # :nodoc:
407408
if node.namespace.nil?
408409
raise ArgumentError, "Namespace #{@ns[:pending]} has not been defined"
409410
end
411+
410412
@ns = nil
411413
end
412414

0 commit comments

Comments
 (0)