Skip to content

Commit fd2f41f

Browse files
authored
Merge pull request #834 from rails-sqlserver/rubocop-UselessAssignment
Rubocop: Enable Lint/UselessAssignment cop
2 parents b7c6bf3 + 0b98c15 commit fd2f41f

File tree

7 files changed

+24
-18
lines changed

7 files changed

+24
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [#831](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/831) Rubocop: Enable Spacing cops
1212
- [#832](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/832) Rubocop: Enable Bundler cops
1313
- [#833](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/833) Rubocop: Enable Layout/* cops
14+
- [#834](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/834) Rubocop: Enable Lint/UselessAssignment cop
1415

1516
## v6.0.0.rc1
1617

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222

2323
spec = eval(File.read("activerecord-sqlserver-adapter.gemspec"))
2424
ver = spec.dependencies.detect { |d| d.name == "activerecord" }.requirement.requirements.first.last.version
25-
major, minor, tiny, pre = ver.split(".")
25+
major, minor, _tiny, pre = ver.split(".")
2626

2727
if pre
2828
ver
@@ -32,7 +32,7 @@ else
3232
http.use_ssl = true
3333
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
3434
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).find do |data|
35-
a, b, c = data["number"].split(".")
35+
a, b, = data["number"].split(".")
3636
!data["prerelease"] && major == a && (minor.nil? || minor == b)
3737
end["number"]
3838
end

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def version_year
480480
return 2016 if sqlserver_version =~ /vNext/
481481

482482
/SQL Server (\d+)/.match(sqlserver_version).to_a.last.to_s.to_i
483-
rescue StandardError => e
483+
rescue StandardError
484484
2016
485485
end
486486

lib/arel/visitors/sqlserver.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ def visit_Arel_Table o, collector
8484
# Apparently, o.engine.connection can actually be a different adapter
8585
# than sqlserver. Can be removed if fixed in ActiveRecord. See:
8686
# github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/450
87-
table_name = begin
88-
if o.class.engine.connection.respond_to?(:sqlserver?) && o.class.engine.connection.database_prefix_remote_server?
89-
remote_server_table_name(o)
90-
else
87+
table_name =
88+
begin
89+
if o.class.engine.connection.respond_to?(:sqlserver?) && o.class.engine.connection.database_prefix_remote_server?
90+
remote_server_table_name(o)
91+
else
92+
quote_table_name(o.name)
93+
end
94+
rescue Exception
9195
quote_table_name(o.name)
9296
end
93-
rescue Exception => e
94-
quote_table_name(o.name)
95-
end
97+
9698
if o.table_alias
9799
collector << "#{table_name} #{quote_table_name o.table_alias}"
98100
else

test/cases/coerced_tests.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class EachTest < ActiveRecord::TestCase
619619
# Quoting in tests does not cope with bracket quoting.
620620
coerce_tests! :test_find_in_batches_should_quote_batch_order
621621
def test_find_in_batches_should_quote_batch_order_coerced
622-
c = Post.connection
622+
Post.connection
623623
assert_sql(/ORDER BY \[posts\]\.\[id\]/) do
624624
Post.find_in_batches(:batch_size => 1) do |batch|
625625
assert_kind_of Array, batch
@@ -631,7 +631,7 @@ def test_find_in_batches_should_quote_batch_order_coerced
631631
# Quoting in tests does not cope with bracket quoting.
632632
coerce_tests! :test_in_batches_should_quote_batch_order
633633
def test_in_batches_should_quote_batch_order_coerced
634-
c = Post.connection
634+
Post.connection
635635
assert_sql(/ORDER BY \[posts\]\.\[id\]/) do
636636
Post.in_batches(of: 1) do |relation|
637637
assert_kind_of ActiveRecord::Relation, relation
@@ -758,7 +758,7 @@ def test_a_bad_type_column_coerced
758758
# Use Square brackets around column name
759759
coerce_tests! :test_eager_load_belongs_to_primary_key_quoting
760760
def test_eager_load_belongs_to_primary_key_quoting_coerced
761-
con = Account.connection
761+
Account.connection
762762
assert_sql(/\[companies\]\.\[id\] = @0.* @0 = 1/) do
763763
Account.all.merge!(:includes => :firm).find(1)
764764
end

test/cases/specific_schema_test_sqlserver.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ class SpecificSchemaTestSQLServer < ActiveRecord::TestCase
2323
end
2424

2525
it "quote table names properly even when they are views" do
26-
obj = SSTestQuotedTable.create!
26+
SSTestQuotedTable.create!
2727
assert_nothing_raised { assert SSTestQuotedTable.first }
28-
obj = SSTestQuotedTableUser.create!
28+
29+
SSTestQuotedTableUser.create!
2930
assert_nothing_raised { assert SSTestQuotedTableUser.first }
30-
obj = SSTestQuotedView1.create!
31+
32+
SSTestQuotedView1.create!
3133
assert_nothing_raised { assert SSTestQuotedView1.first }
32-
obj = SSTestQuotedView2.create!
34+
35+
SSTestQuotedView2.create!
3336
assert_nothing_raised { assert SSTestQuotedView2.first }
3437
end
3538

test/cases/transaction_test_sqlserver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
2626
raise "HELL"
2727
end
2828
end
29-
rescue Exception => e
29+
rescue Exception
3030
assert_no_ships
3131
end
3232
end

0 commit comments

Comments
 (0)