Skip to content

Commit 0f56af3

Browse files
committed
Lint/UnusedBlockArgument
1 parent 97ea80d commit 0f56af3

File tree

9 files changed

+24
-45
lines changed

9 files changed

+24
-45
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
# This configuration was generated by `rubocop --auto-gen-config`
2-
# on 2015-03-12 17:46:52 -0700 using RuboCop version 0.29.1.
2+
# on 2015-03-12 18:00:35 -0700 using RuboCop version 0.29.1.
33
# The point is for the user to remove these configuration records
44
# one by one as the offenses are removed from the code base.
55
# Note that changes in the inspected code, or installation of new
66
# versions of RuboCop, may require this file to be generated again.
77

8-
# Offense count: 2
9-
Lint/ShadowingOuterLocalVariable:
10-
Enabled: false
11-
12-
# Offense count: 23
13-
# Cop supports --auto-correct.
14-
Lint/UnusedBlockArgument:
15-
Enabled: false
16-
178
# Offense count: 1
189
Lint/UselessAccessModifier:
1910
Enabled: false
2011

21-
# Offense count: 4
12+
# Offense count: 10
2213
Lint/UselessAssignment:
2314
Enabled: false
2415

benchmark/query_with_mysql_casting.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def mysql_cast(type, value)
4343
mysql2.query "USE #{database}"
4444
x.report "Mysql2" do
4545
mysql2_result = mysql2.query sql, :symbolize_keys => true
46-
mysql2_result.each do |res|
47-
# puts res.inspect
48-
end
46+
# mysql2_result.each { |res| puts res.inspect }
4947
end
5048

5149
mysql = Mysql.new("localhost", "root")
@@ -55,7 +53,7 @@ def mysql_cast(type, value)
5553
fields = mysql_result.fetch_fields
5654
mysql_result.each do |row|
5755
row_hash = row.each_with_index.each_with_object({}) do |(f, j), hash|
58-
hash[fields[j].name.to_sym] = mysql_cast(fields[j].type, row[j])
56+
hash[fields[j].name.to_sym] = mysql_cast(fields[j].type, f)
5957
end
6058
# puts row_hash.inspect
6159
end
@@ -65,9 +63,7 @@ def mysql_cast(type, value)
6563
command = do_mysql.create_command sql
6664
x.report "do_mysql" do
6765
do_result = command.execute_reader
68-
do_result.each do |res|
69-
# puts res.inspect
70-
end
66+
# do_result.each { |res| puts res.inspect }
7167
end
7268

7369
x.compare!

benchmark/query_without_mysql_casting.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,26 @@
1515
mysql2.query "USE #{database}"
1616
x.report "Mysql2 (cast: true)" do
1717
mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => true
18-
mysql2_result.each do |res|
19-
# puts res.inspect
20-
end
18+
# mysql2_result.each { |res| puts res.inspect }
2119
end
2220

2321
x.report "Mysql2 (cast: false)" do
2422
mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => false
25-
mysql2_result.each do |res|
26-
# puts res.inspect
27-
end
23+
# mysql2_result.each { |res| puts res.inspect }
2824
end
2925

3026
mysql = Mysql.new("localhost", "root")
3127
mysql.query "USE #{database}"
3228
x.report "Mysql" do
3329
mysql_result = mysql.query sql
34-
mysql_result.each_hash do |res|
35-
# puts res.inspect
36-
end
30+
# mysql_result.each_hash { |res| puts res.inspect }
3731
end
3832

3933
do_mysql = DataObjects::Connection.new("mysql://localhost/#{database}")
4034
command = DataObjects::Mysql::Command.new do_mysql, sql
4135
x.report "do_mysql" do
4236
do_result = command.execute_reader
43-
do_result.each do |res|
44-
# puts res.inspect
45-
end
37+
# do_result.each { |res| puts res.inspect }
4638
end
4739

4840
x.compare!

ext/mysql2/extconf.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def asplode(lib)
117117
# Use rake to rebuild only if these files change
118118
deffile = File.expand_path('../../../support/libmysql.def', __FILE__)
119119
libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
120-
file 'libmysql.a' => [deffile, libfile] do |t|
120+
file 'libmysql.a' => [deffile, libfile] do
121121
when_writing 'building libmysql.a' do
122122
# Ruby kindly shows us where dllwrap is, but that tool does more than we want.
123123
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
@@ -144,7 +144,7 @@ def asplode(lib)
144144

145145
vendordll = File.join(vendordir, 'libmysql.dll')
146146
dllfile = File.expand_path(File.join(rpath_dir, 'libmysql.dll'))
147-
file vendordll => [dllfile, vendordir] do |t|
147+
file vendordll => [dllfile, vendordir] do
148148
when_writing 'copying libmysql.dll' do
149149
cp dllfile, vendordll
150150
end

lib/mysql2/console.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Loaded by script/console. Land helpers here.
22

3-
Pry.config.prompt = lambda do |context, nesting, pry|
3+
Pry.config.prompt = lambda do |context, *|
44
"[mysql2] #{context}> "
55
end

spec/em/em_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
EM.run do
5454
client = Mysql2::EM::Client.new DatabaseCredentials['root']
5555
defer = client.query "SELECT sleep(0.1) as first_query"
56-
defer.callback do |result|
56+
defer.callback do
5757
client.close
5858
fail 'some error'
5959
end
60-
defer.errback do |err|
60+
defer.errback do
6161
# This _shouldn't_ be run, but it needed to prevent the specs from
6262
# freezing if this test fails.
6363
EM.stop_event_loop
@@ -75,7 +75,7 @@
7575
errors = []
7676
EM.run do
7777
defer = client.query "SELECT sleep(0.1) as first_query"
78-
defer.callback do |result|
78+
defer.callback do
7979
# This _shouldn't_ be run, but it is needed to prevent the specs from
8080
# freezing if this test fails.
8181
EM.stop_event_loop
@@ -93,13 +93,13 @@
9393
EM.run do
9494
defer = client.query "SELECT sleep(0.025) as first_query"
9595
EM.add_timer(0.1) do
96-
defer.callback do |result|
96+
defer.callback do
9797
callbacks_run << :callback
9898
# This _shouldn't_ be run, but it is needed to prevent the specs from
9999
# freezing if this test fails.
100100
EM.stop_event_loop
101101
end
102-
defer.errback do |err|
102+
defer.errback do
103103
callbacks_run << :errback
104104
EM.stop_event_loop
105105
end
@@ -114,10 +114,10 @@
114114
EM.run do
115115
client = Mysql2::EM::Client.new DatabaseCredentials['root']
116116
defer = client.query("select sleep(0.025)")
117-
defer.callback do |result|
117+
defer.callback do
118118
callbacks_run << :callback
119119
end
120-
defer.errback do |err|
120+
defer.errback do
121121
callbacks_run << :errback
122122
end
123123
EM.add_timer(0.1) do

spec/mysql2/result_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
res = client.query "SELECT * FROM streamingTest", :stream => true, :cache_rows => false
159159

160160
expect {
161-
res.each_with_index do |row, i|
161+
res.each_with_index do |_, i|
162162
# Exhaust the first result packet then trigger a timeout
163163
sleep 2 if i > 0 && i % 1000 == 0
164164
end

tasks/compile.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Rake::ExtensionTask.new("mysql2", Mysql2::GEMSPEC) do |ext|
5050
end
5151
Rake::Task[:spec].prerequisites << :compile
5252

53-
file 'vendor/README' do |t|
53+
file 'vendor/README' do
5454
connector_dir = File.expand_path("../../vendor/#{vendor_mysql_dir}", __FILE__)
5555
when_writing 'copying Connector/C README' do
5656
cp "#{connector_dir}/README", 'vendor/README'

tasks/vendor_mysql.rake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def vendor_mysql_url(*args)
2121
end
2222

2323
# vendor:mysql
24-
task "vendor:mysql:cross" do |t|
24+
task "vendor:mysql:cross" do
2525
# When cross-compiling, grab both 32 and 64 bit connectors
2626
Rake::Task['vendor:mysql'].invoke('x86')
2727
Rake::Task['vendor:mysql'].invoke('x64')
2828
end
2929

30-
task "vendor:mysql", [:platform] do |t, args|
30+
task "vendor:mysql", [:platform] do |_t, args|
3131
puts "vendor:mysql for #{vendor_mysql_dir(args[:platform])}"
3232

3333
# download mysql library and headers
@@ -37,7 +37,7 @@ task "vendor:mysql", [:platform] do |t, args|
3737
url = vendor_mysql_url(args[:platform])
3838
when_writing "downloading #{t.name}" do
3939
cd "vendor" do
40-
sh "curl", "-C", "-", "-O", url do |ok, res|
40+
sh "curl", "-C", "-", "-O", url do |ok|
4141
sh "wget", "-c", url unless ok
4242
end
4343
end

0 commit comments

Comments
 (0)