Skip to content

Commit 41fd23a

Browse files
committed
Enable Style/MapToHash cop
Related to rails/rails#44555 ```ruby $ bundle exec rubocop -A Inspecting 72 files .......C................................................................ Offenses: lib/active_record/connection_adapters/oracle_enhanced/connection.rb:104:37: C: [Corrected] Style/MapToHash: Pass a block to to_h instead of calling map.to_h. columns.each_with_index.map { |x, i| [x, row[i]] }.to_h if row ^^^ 72 files inspected, 1 offense detected, 1 offense corrected $ ```
1 parent 6ea02b0 commit 41fd23a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ Style/FrozenStringLiteralComment:
132132
Enabled: true
133133
EnforcedStyle: always
134134

135+
Style/MapToHash:
136+
Enabled: true
137+
135138
Style/RedundantFreeze:
136139
Enabled: true
137140

lib/active_record/connection_adapters/oracle_enhanced/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _select_one(arel, name = nil, binds = [])
101101
_oracle_downcase(col_name)
102102
end
103103
row = cursor.fetch
104-
columns.each_with_index.map { |x, i| [x, row[i]] }.to_h if row
104+
columns.each_with_index.to_h { |x, i| [x, row[i]] } if row
105105
ensure
106106
cursor.close
107107
end

0 commit comments

Comments
 (0)