Skip to content

Commit 01a893b

Browse files
committed
Switch rubocop to omakase styles
1 parent 2c7f41f commit 01a893b

11 files changed

+67
-46
lines changed

.rubocop.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
inherit_from: https://raw.githubusercontent.com/rails/rails/main/.rubocop.yml
1+
# Omakase Ruby styling for Rails
2+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }

Gemfile

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,4 @@ gemspec
66

77
gem "rake"
88
gem "debug", ">= 1.0.0"
9-
gem "rubocop"
10-
gem "rubocop-minitest"
11-
gem "rubocop-packaging"
12-
gem "rubocop-performance"
13-
gem "rubocop-rails"
14-
gem "rubocop-md"
9+
gem "rubocop-rails-omakase"

Gemfile.lock

+23-25
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ GEM
8484
io-console (0.6.0)
8585
irb (1.7.1)
8686
reline (>= 0.3.0)
87-
json (2.6.3)
87+
json (2.7.1)
8888
language_server-protocol (3.17.0.3)
8989
loofah (2.9.0)
9090
crass (~> 1.0.2)
@@ -104,8 +104,8 @@ GEM
104104
racc (~> 1.4)
105105
nokogiri (1.15.2-x86_64-darwin)
106106
racc (~> 1.4)
107-
parallel (1.23.0)
108-
parser (3.2.2.3)
107+
parallel (1.24.0)
108+
parser (3.2.2.4)
109109
ast (~> 2.4.1)
110110
racc
111111
racc (1.7.1)
@@ -144,36 +144,39 @@ GEM
144144
redis-client (>= 0.9.0)
145145
redis-client (0.17.0)
146146
connection_pool
147-
regexp_parser (2.8.1)
147+
regexp_parser (2.8.3)
148148
reline (0.3.6)
149149
io-console (~> 0.5)
150-
rexml (3.2.5)
151-
rubocop (1.54.1)
150+
rexml (3.2.6)
151+
rubocop (1.59.0)
152152
json (~> 2.3)
153153
language_server-protocol (>= 3.17.0)
154154
parallel (~> 1.10)
155-
parser (>= 3.2.2.3)
155+
parser (>= 3.2.2.4)
156156
rainbow (>= 2.2.2, < 4.0)
157157
regexp_parser (>= 1.8, < 3.0)
158158
rexml (>= 3.2.5, < 4.0)
159-
rubocop-ast (>= 1.28.0, < 2.0)
159+
rubocop-ast (>= 1.30.0, < 2.0)
160160
ruby-progressbar (~> 1.7)
161161
unicode-display_width (>= 2.4.0, < 3.0)
162-
rubocop-ast (1.29.0)
162+
rubocop-ast (1.30.0)
163163
parser (>= 3.2.1.0)
164-
rubocop-md (1.2.0)
165-
rubocop (>= 1.0)
166-
rubocop-minitest (0.31.0)
164+
rubocop-minitest (0.34.2)
167165
rubocop (>= 1.39, < 2.0)
168-
rubocop-packaging (0.5.2)
169-
rubocop (>= 1.33, < 2.0)
170-
rubocop-performance (1.18.0)
171-
rubocop (>= 1.7.0, < 2.0)
172-
rubocop-ast (>= 0.4.0)
173-
rubocop-rails (2.20.2)
166+
rubocop-ast (>= 1.30.0, < 2.0)
167+
rubocop-performance (1.20.1)
168+
rubocop (>= 1.48.1, < 2.0)
169+
rubocop-ast (>= 1.30.0, < 2.0)
170+
rubocop-rails (2.23.1)
174171
activesupport (>= 4.2.0)
175172
rack (>= 1.1)
176173
rubocop (>= 1.33.0, < 2.0)
174+
rubocop-ast (>= 1.30.0, < 2.0)
175+
rubocop-rails-omakase (1.0.0)
176+
rubocop
177+
rubocop-minitest
178+
rubocop-performance
179+
rubocop-rails
177180
ruby-progressbar (1.13.0)
178181
sprockets (4.0.2)
179182
concurrent-ruby (~> 1.0)
@@ -185,7 +188,7 @@ GEM
185188
thor (1.1.0)
186189
tzinfo (2.0.4)
187190
concurrent-ruby (~> 1.0)
188-
unicode-display_width (2.4.2)
191+
unicode-display_width (2.5.0)
189192
websocket-driver (0.7.3)
190193
websocket-extensions (>= 0.1.0)
191194
websocket-extensions (0.1.5)
@@ -201,12 +204,7 @@ DEPENDENCIES
201204
kredis!
202205
rails (>= 6.0.0)
203206
rake
204-
rubocop
205-
rubocop-md
206-
rubocop-minitest
207-
rubocop-packaging
208-
rubocop-performance
209-
rubocop-rails
207+
rubocop-rails-omakase
210208

211209
BUNDLED WITH
212210
2.3.12

bin/rubocop

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rubocop' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("rubocop", "rubocop")

test/attributes_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class Person
1212
kredis_list :names
1313
kredis_list :names_with_custom_key_via_lambda, key: ->(p) { "person:#{p.id}:names_customized" }
1414
kredis_list :names_with_custom_key_via_method, key: :generate_key
15-
kredis_list :names_with_default_via_lambda, default: ->(p) { ["Random", p.name] }
15+
kredis_list :names_with_default_via_lambda, default: ->(p) { [ "Random", p.name ] }
1616
kredis_unique_list :skills, limit: 2
17-
kredis_unique_list :skills_with_default_via_lambda, default: ->(p) { ["Random", "Random", p.name] }
17+
kredis_unique_list :skills_with_default_via_lambda, default: ->(p) { [ "Random", "Random", p.name ] }
1818
kredis_ordered_set :reading_list, limit: 2
1919
kredis_flag :special
2020
kredis_flag :temporary_special, expires_in: 1.second
@@ -70,7 +70,7 @@ def eye_color
7070
end
7171

7272
def scores
73-
[10, 28, 2, 7].to_json
73+
[ 10, 28, 2, 7 ].to_json
7474
end
7575

7676
def hourly_wage

test/callbacks_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CallbacksTest < ActiveSupport::TestCase
4848
vacations = Kredis.set "vacations", after_change: ->(set) { @callback_check = set.members }
4949
vacations.add "paris"
5050

51-
assert_equal ["paris"], @callback_check
51+
assert_equal [ "paris" ], @callback_check
5252
end
5353

5454
test "hash with after_change proc callback" do

test/connections_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ class ConnectionsTest < ActiveSupport::TestCase
3434

3535
Kredis.configurator.stub(:config_for, fixture_config) do
3636
Kredis.configurator.stub(:root, Pathname.new(Dir.pwd).join("test/fixtures")) do
37-
assert_match %r|redis://127.0.0.1:6379/4|, Kredis.redis.inspect
37+
assert_match %r{redis://127.0.0.1:6379/4}, Kredis.redis.inspect
3838
end
3939
end
4040
end
4141

4242
test "default config in env" do
4343
ENV["REDIS_URL"] = "redis://127.0.0.1:6379/3"
44-
assert_match %r|redis://127.0.0.1:6379/3|, Kredis.redis.inspect
44+
assert_match %r{redis://127.0.0.1:6379/3}, Kredis.redis.inspect
4545
ensure
4646
ENV.delete("REDIS_URL")
4747
end
4848

4949
test "default config without env" do
50-
assert_match %r|redis://127.0.0.1:6379/0|, Kredis.redis.inspect
50+
assert_match %r{redis://127.0.0.1:6379/0}, Kredis.redis.inspect
5151
end
5252

5353
test "custom config is missing" do

test/types/hash_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class HashTest < ActiveSupport::TestCase
9797
@hash = Kredis.hash "myhash", typed: :integer, default: { space_invaders: "100", pong: "42" }
9898
assert_equal({ "space_invaders" => 100, "pong" => 42 }, @hash.to_h)
9999
assert_equal(%w[ space_invaders pong ], @hash.keys)
100-
assert_equal([100, 42], @hash.values)
100+
assert_equal([ 100, 42 ], @hash.values)
101101
assert_equal(100, @hash["space_invaders"])
102-
assert_equal([100, 42], @hash.values_at("space_invaders", "pong"))
102+
assert_equal([ 100, 42 ], @hash.values_at("space_invaders", "pong"))
103103
end
104104

105105
test "update with default" do

test/types/ordered_set_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OrderedSetTest < ActiveSupport::TestCase
2323
test "mass append maintains ordering" do
2424
@set = Kredis.ordered_set "ordered-set" # no limit
2525

26-
thousand_elements = 1000.times.map { [*"A".."Z"].sample(10).join }
26+
thousand_elements = 1000.times.map { [ *"A".."Z" ].sample(10).join }
2727
@set.append(thousand_elements)
2828
assert_equal thousand_elements, @set.elements
2929

test/types/scalar_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class ScalarTest < ActiveSupport::TestCase
7979
json.value = { "one" => 1, "string" => "hello" }
8080
assert_equal({ "one" => 1, "string" => "hello" }, json.value)
8181

82-
json.value = { "json_class" => "String", "raw" => [97, 98, 99] }
83-
assert_equal({ "json_class" => "String", "raw" => [97, 98, 99] }, json.value)
82+
json.value = { "json_class" => "String", "raw" => [ 97, 98, 99 ] }
83+
assert_equal({ "json_class" => "String", "raw" => [ 97, 98, 99 ] }, json.value)
8484
end
8585

8686
test "invalid type" do

test/types/set_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SetTest < ActiveSupport::TestCase
2121

2222
test "remove" do
2323
@set.add(%w[ 1 2 3 4 ])
24-
@set.remove([%w[ 2 3 ]])
24+
@set.remove([ %w[ 2 3 ] ])
2525
@set.remove("1")
2626
assert_equal %w[ 4 ], @set.members
2727
end
@@ -125,7 +125,7 @@ class SetTest < ActiveSupport::TestCase
125125
test "add with default" do
126126
@set = Kredis.set "mylist", typed: :integer, default: -> () { %w[ 1 2 3 ] }
127127
@set.add(%w[ 5 6 7 ])
128-
assert_equal [1, 2, 3, 5, 6, 7], @set.members
128+
assert_equal [ 1, 2, 3, 5, 6, 7 ], @set.members
129129
end
130130

131131
test "remove with default" do

0 commit comments

Comments
 (0)