Skip to content

Commit 568cecd

Browse files
author
Stanislav Katkov
committed
rubocop safe corrections
1 parent d4cf51b commit 568cecd

File tree

12 files changed

+24
-30
lines changed

12 files changed

+24
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
ruby-version: 3.2.2
1515
bundler-cache: true
1616
- name: Run Rubocop
17-
run: bin/rubocop
17+
run: bundle exec rubocop --parallel
1818
tests:
1919
name: Tests
2020
runs-on: ubuntu-latest

Gemfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ gem "appraisal"
1616
# gem "debug", ">= 1.0.0"
1717

1818
group :rubocop do
19-
gem "rubocop", ">= 1.25.1", require: false
20-
gem "rubocop-minitest", require: false
21-
gem "rubocop-packaging", require: false
22-
gem "rubocop-performance", require: false
23-
gem "rubocop-rails", require: false
24-
gem "rubocop-md", require: false
19+
gem "rubocop", ">= 1.25.1", require: false
20+
gem "rubocop-minitest", require: false
21+
gem "rubocop-packaging", require: false
22+
gem "rubocop-performance", require: false
23+
gem "rubocop-rails", require: false
24+
gem "rubocop-md", require: false
2525
end

app/models/solid_cache/record.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ class Record < ActiveRecord::Base
44

55
self.abstract_class = true
66

7-
connects_to **SolidCache.connects_to if SolidCache.connects_to
7+
connects_to(**SolidCache.connects_to) if SolidCache.connects_to
88

99
class << self
10-
def disable_instrumentation
11-
connection.with_instrumenter(NULL_INSTRUMENTER) do
12-
yield
13-
end
10+
def disable_instrumentation(&block)
11+
connection.with_instrumenter(NULL_INSTRUMENTER, &block)
1412
end
1513

1614
def with_shard(shard, &block)

bin/irb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rdbg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

bin/rubocop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1313
bundle_binstub = File.expand_path("bundle", __dir__)
1414

1515
if File.file?(bundle_binstub)
16-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
1717
load(bundle_binstub)
1818
else
1919
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

lib/solid_cache.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def self.all_shards_config
1717
connects_to && connects_to[:shards]
1818
end
1919

20-
def self.each_shard
20+
def self.each_shard(&block)
2121
return to_enum(:each_shard) unless block_given?
2222

2323
if (shards = all_shards_config&.keys)
2424
shards.each do |shard|
25-
Record.connected_to(shard: shard) { yield }
25+
Record.connected_to(shard: shard, &block)
2626
end
2727
else
2828
yield

lib/solid_cache/cluster/expiry.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def expire_later
3434
end
3535

3636
def expiry_counter
37-
@expiry_counters ||= connection_names.to_h { |connection_name| [ connection_name, Counter.new(expire_every) ] }
37+
@expiry_counters ||= connection_names.index_with { |connection_name| Counter.new(expire_every) }
3838
@expiry_counters[Entry.current_shard]
3939
end
4040

lib/solid_cache/store/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def read_serialized_entries(keys)
7474
end
7575

7676
def read_multi_entries(names, **options)
77-
keys_and_names = names.to_h { |name| [ normalize_key(name, options), name ] }
77+
keys_and_names = names.index_by { |name| normalize_key(name, options) }
7878
serialized_entries = read_serialized_entries(keys_and_names.keys)
7979

8080
keys_and_names.each_with_object({}) do |(key, name), results|

0 commit comments

Comments
 (0)