Skip to content

Commit 45c9559

Browse files
committed
style(rubocop): SpaceInsideHashLiteralBraces, RedundantParentheses
1 parent 304e7b4 commit 45c9559

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

lib/nokogiri/html4/encoding_reader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def read(len)
108108

109109
ret = @firstchunk.slice!(0, len)
110110
if (len -= ret.length) > 0
111-
(rest = @io.read(len)) && ret << (rest)
111+
(rest = @io.read(len)) && ret << rest
112112
end
113113
if ret.empty?
114114
nil

test/html4/sax/test_push_parser.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let(:parser) { Nokogiri::HTML4::SAX::PushParser.new(Nokogiri::SAX::TestCase::Doc.new) }
88

99
it :test_end_document_called do
10-
parser << (<<~HTML)
10+
parser << <<~HTML
1111
<p id="asdfasdf">
1212
<!-- This is a comment -->
1313
Paragraph 1
@@ -19,7 +19,7 @@
1919
end
2020

2121
it :test_start_element do
22-
parser << (<<~HTML)
22+
parser << <<~HTML
2323
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2424
<html><head><body><p id="asdfasdf">
2525
HTML
@@ -29,7 +29,7 @@
2929
parser.document.start_elements,
3030
)
3131

32-
parser << (<<~HTML)
32+
parser << <<~HTML
3333
<!-- This is a comment -->
3434
Paragraph 1
3535
</p></body></html>
@@ -39,11 +39,11 @@
3939
end
4040

4141
it :test_chevron_partial_html do
42-
parser << (<<~HTML)
42+
parser << <<~HTML
4343
<p id="asdfasdf">
4444
HTML
4545

46-
parser << (<<-HTML)
46+
parser << <<~HTML
4747
<!-- This is a comment -->
4848
Paragraph 1
4949
</p>
@@ -53,7 +53,7 @@
5353
end
5454

5555
it :test_chevron do
56-
parser << (<<~HTML)
56+
parser << <<~HTML
5757
<p id="asdfasdf">
5858
<!-- This is a comment -->
5959
Paragraph 1

test/html4/test_comments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class TestComment < Nokogiri::TestCase
250250
{
251251
name: "div", children: [
252252
{ name: "comment", content: "[if foo]" },
253-
{ name: "div", attributes: [{name: "id", value: "do-i-exist"}] },
253+
{ name: "div", attributes: [{ name: "id", value: "do-i-exist" }] },
254254
{ name: "comment", content: "[endif]" },
255255
]
256256
}

test/html4/test_document_fragment.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ def test_malformed_fragment_is_corrected
193193
assert_pattern do
194194
fragment => [
195195
{ name: "div", attributes: [
196-
{ name: "<", value: ""},
197-
{ name: "div", value: ""},
198-
]}
196+
{ name: "<", value: "" },
197+
{ name: "div", value: "" },
198+
] }
199199
]
200200
end
201201
else

test/test_pattern_matching.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@
258258

259259
it "finds node contents" do
260260
assert_pattern do
261-
doc => { root: { children: [*, { children: [*, {name: "grandchild1", content: }, *] }, *] } }
261+
doc => { root: { children: [*, { children: [*, { name: "grandchild1", content: }, *] }, *] } }
262262
assert_equal("hello & goodbye", content)
263263
end
264264
end
265265

266266
it "finds node contents by attribute" do
267267
assert_pattern do
268-
doc => { root: { children: [*, { children: [*, {attributes: [*, {name: "size", value: "small"}, *], content: }, *] }, *] } }
268+
doc => { root: { children: [*, { children: [*, { attributes: [*, { name: "size", value: "small" }, *], content: }, *] }, *] } }
269269
assert_equal("hello & goodbye", content)
270270
end
271271
end
@@ -274,13 +274,13 @@
274274
describe "Fragment" do
275275
it "finds nodes" do
276276
assert_pattern do
277-
frag => [{name: "child1"}, {name: "child2"}, {name: "child3"}, {content: "\n"}]
277+
frag => [{ name: "child1" }, { name: "child2" }, { name: "child3" }, { content: "\n" }]
278278
end
279279
end
280280

281281
it "finds attributes" do
282282
assert_pattern do
283-
frag => [*, {name: "child2", attributes: }, *]
283+
frag => [*, { name: "child2", attributes: }, *]
284284
assert_equal("foo", attributes.first.name)
285285
end
286286
end
@@ -289,7 +289,7 @@
289289
describe "Node" do
290290
it "finds nodes" do
291291
assert_pattern do
292-
doc.root => { elements: [{name: "child1"}, {name: "child2"}, {name: "child3"}] }
292+
doc.root => { elements: [{ name: "child1" }, { name: "child2" }, { name: "child3" }] }
293293
end
294294
end
295295
end

test/xml/node/test_save_options.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def test_predicate_#{constant.downcase}
1919

2020
def test_default_xml_save_options
2121
if Nokogiri.jruby?
22-
assert_equal(0, (SaveOptions::DEFAULT_XML & SaveOptions::FORMAT))
22+
assert_equal(0, SaveOptions::DEFAULT_XML & SaveOptions::FORMAT)
2323
else
24-
assert_equal(SaveOptions::FORMAT, (SaveOptions::DEFAULT_XML & SaveOptions::FORMAT))
24+
assert_equal(SaveOptions::FORMAT, SaveOptions::DEFAULT_XML & SaveOptions::FORMAT)
2525
end
2626
end
2727
end

test/xml/sax/test_push_parser.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def error(msg)
8888
end
8989

9090
it :test_end_document_called do
91-
parser << (<<~XML)
91+
parser << <<~XML
9292
<p id="asdfasdf">
9393
<!-- This is a comment -->
9494
Paragraph 1
@@ -100,14 +100,14 @@ def error(msg)
100100
end
101101

102102
it :test_start_element do
103-
parser << (<<~XML)
103+
parser << <<~XML
104104
<p id="asdfasdf">
105105
XML
106106

107107
assert_equal [["p", [["id", "asdfasdf"]]]],
108108
parser.document.start_elements
109109

110-
parser << (<<~XML)
110+
parser << <<~XML
111111
<!-- This is a comment -->
112112
Paragraph 1
113113
</p>
@@ -117,14 +117,14 @@ def error(msg)
117117
end
118118

119119
it :test_start_element_with_namespaces do
120-
parser << (<<~XML)
120+
parser << <<~XML
121121
<p xmlns:foo="http://foo.example.com/">
122122
XML
123123

124124
assert_equal [["p", [["xmlns:foo", "http://foo.example.com/"]]]],
125125
parser.document.start_elements
126126

127-
parser << (<<~XML)
127+
parser << <<~XML
128128
<!-- This is a comment -->
129129
Paragraph 1
130130
</p>
@@ -134,7 +134,7 @@ def error(msg)
134134
end
135135

136136
it :test_start_element_ns do
137-
parser << (<<~XML)
137+
parser << <<~XML
138138
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' size='large'></stream:stream>
139139
XML
140140

@@ -152,7 +152,7 @@ def error(msg)
152152
end
153153

154154
it :test_end_element_ns do
155-
parser << (<<~XML)
155+
parser << <<~XML
156156
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'></stream:stream>
157157
XML
158158

@@ -162,11 +162,11 @@ def error(msg)
162162
end
163163

164164
it :test_chevron_partial_xml do
165-
parser << (<<~XML)
165+
parser << <<~XML
166166
<p id="asdfasdf">
167167
XML
168168

169-
parser << (<<~XML)
169+
parser << <<~XML
170170
<!-- This is a comment -->
171171
Paragraph 1
172172
</p>
@@ -176,7 +176,7 @@ def error(msg)
176176
end
177177

178178
it :test_chevron do
179-
parser << (<<~XML)
179+
parser << <<~XML
180180
<p id="asdfasdf">
181181
<!-- This is a comment -->
182182
Paragraph 1
@@ -192,7 +192,7 @@ def error(msg)
192192

193193
it :test_recover do
194194
parser.options |= Nokogiri::XML::ParseOptions::RECOVER
195-
parser << (<<~XML)
195+
parser << <<~XML
196196
<p>
197197
Foo
198198
<bar>
@@ -248,7 +248,7 @@ def error(msg)
248248

249249
it :test_untouched_entities do
250250
skip_unless_libxml2("entities are always replaced in pure Java version")
251-
parser << (<<~XML)
251+
parser << <<~XML
252252
<p id="asdf&amp;asdf">
253253
<!-- This is a comment -->
254254
Paragraph 1 &amp; 2
@@ -261,7 +261,7 @@ def error(msg)
261261

262262
it :test_replaced_entities do
263263
parser.replace_entities = true
264-
parser << (<<~XML)
264+
parser << <<~XML
265265
<p id="asdf&amp;asdf">
266266
<!-- This is a comment -->
267267
Paragraph 1 &amp; 2

test/xml/test_node.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_node_context_parsing_of_malformed_html_fragment
109109
assert_empty(doc.errors)
110110
assert_pattern do
111111
nodeset => [
112-
{ name: "div", attributes: [{name: "<", value: ""}, { name: "div", value: ""}] },
112+
{ name: "div", attributes: [{ name: "<", value: "" }, { name: "div", value: "" }] },
113113
]
114114
end
115115
else
@@ -131,7 +131,7 @@ def test_node_context_parsing_of_malformed_html_fragment_with_recover_is_correct
131131
assert_empty(doc.errors)
132132
assert_pattern do
133133
nodeset => [
134-
{ name: "div", attributes: [{name: "<", value: ""}, { name: "div", value: ""}] },
134+
{ name: "div", attributes: [{ name: "<", value: "" }, { name: "div", value: "" }] },
135135
]
136136
end
137137
else
@@ -461,7 +461,7 @@ def test_description
461461

462462
def test_spaceship
463463
nodes = xml.xpath("//employee")
464-
assert_equal(-1, (nodes.first <=> nodes.last))
464+
assert_equal(-1, nodes.first <=> nodes.last)
465465
list = [nodes.first, nodes.last].sort
466466
assert_equal(nodes.first, list.first)
467467
assert_equal(nodes.last, list.last)

0 commit comments

Comments
 (0)