Skip to content

Commit f2f6185

Browse files
committed
Add rubocop-rails-omakase and fix flagged problems
1 parent 35f0b35 commit f2f6185

14 files changed

+81
-10
lines changed

.github/workflows/main.yml

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ name: Build
22
on: [push, pull_request]
33

44
jobs:
5+
rubocop:
6+
name: Rubocop
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v3
11+
- name: Setup Ruby and install gems
12+
uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 3.0
15+
bundler-cache: true
16+
- name: Run rubocop
17+
run: |
18+
bundle exec rubocop --parallel
519
tests:
620
name: Tests
721
runs-on: ubuntu-latest

.rubocop.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Want to disable a check for a specific case? To disable checks inline:
2+
# http://docs.rubocop.org/en/latest/configuration/#disabling-cops-within-source-code
3+
4+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
5+
6+
AllCops:
7+
TargetRubyVersion: 3.0
8+
Exclude:
9+
- "test/dummy/db/schema.rb"

Gemfile.lock

+42
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ GEM
4545
minitest (>= 5.1)
4646
mutex_m
4747
tzinfo (~> 2.0)
48+
ast (2.4.2)
4849
base64 (0.1.1)
4950
bigdecimal (3.1.4)
5051
builder (3.2.4)
@@ -69,6 +70,8 @@ GEM
6970
io-console (0.6.0)
7071
irb (1.6.2)
7172
reline (>= 0.3.0)
73+
json (2.7.1)
74+
language_server-protocol (3.17.0.3)
7275
loofah (2.21.4)
7376
crass (~> 1.0.2)
7477
nokogiri (>= 1.12.0)
@@ -85,6 +88,10 @@ GEM
8588
racc (~> 1.4)
8689
nokogiri (1.16.2-x86_64-linux)
8790
racc (~> 1.4)
91+
parallel (1.24.0)
92+
parser (3.3.0.5)
93+
ast (~> 2.4.1)
94+
racc
8895
pg (1.5.4)
8996
puma (6.4.2)
9097
nio4r (~> 2.0)
@@ -113,16 +120,50 @@ GEM
113120
rake (>= 12.2)
114121
thor (~> 1.0, >= 1.2.2)
115122
zeitwerk (~> 2.6)
123+
rainbow (3.1.1)
116124
rake (13.0.6)
125+
regexp_parser (2.9.0)
117126
reline (0.3.2)
118127
io-console (~> 0.5)
128+
rexml (3.2.6)
129+
rubocop (1.62.1)
130+
json (~> 2.3)
131+
language_server-protocol (>= 3.17.0)
132+
parallel (~> 1.10)
133+
parser (>= 3.3.0.2)
134+
rainbow (>= 2.2.2, < 4.0)
135+
regexp_parser (>= 1.8, < 3.0)
136+
rexml (>= 3.2.5, < 4.0)
137+
rubocop-ast (>= 1.31.1, < 2.0)
138+
ruby-progressbar (~> 1.7)
139+
unicode-display_width (>= 2.4.0, < 3.0)
140+
rubocop-ast (1.31.2)
141+
parser (>= 3.3.0.4)
142+
rubocop-minitest (0.35.0)
143+
rubocop (>= 1.61, < 2.0)
144+
rubocop-ast (>= 1.31.1, < 2.0)
145+
rubocop-performance (1.21.0)
146+
rubocop (>= 1.48.1, < 2.0)
147+
rubocop-ast (>= 1.31.1, < 2.0)
148+
rubocop-rails (2.24.1)
149+
activesupport (>= 4.2.0)
150+
rack (>= 1.1)
151+
rubocop (>= 1.33.0, < 2.0)
152+
rubocop-ast (>= 1.31.1, < 2.0)
153+
rubocop-rails-omakase (1.0.0)
154+
rubocop
155+
rubocop-minitest
156+
rubocop-performance
157+
rubocop-rails
158+
ruby-progressbar (1.13.0)
119159
ruby2_keywords (0.0.5)
120160
sqlite3 (1.5.4)
121161
mini_portile2 (~> 2.8.0)
122162
thor (1.2.2)
123163
timeout (0.4.1)
124164
tzinfo (2.0.6)
125165
concurrent-ruby (~> 1.0)
166+
unicode-display_width (2.5.0)
126167
webrick (1.8.1)
127168
zeitwerk (2.6.12)
128169

@@ -138,6 +179,7 @@ DEPENDENCIES
138179
mysql2
139180
pg
140181
puma
182+
rubocop-rails-omakase
141183
solid_queue!
142184
sqlite3
143185

app/models/solid_queue/failed_execution.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ def expand_error_details_from_exception
3333
self.error = { exception_class: exception.class.name, message: exception.message, backtrace: exception.backtrace }
3434
end
3535
end
36-
end
36+
end
3737
end

lib/solid_queue/dispatcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def set_procline
5252
end
5353

5454
def metadata
55-
super.merge(batch_size: batch_size, concurrency_maintenance_interval: concurrency_maintenance&.interval, recurring_schedule: recurring_schedule.tasks.presence )
55+
super.merge(batch_size: batch_size, concurrency_maintenance_interval: concurrency_maintenance&.interval, recurring_schedule: recurring_schedule.tasks.presence)
5656
end
5757
end
5858
end

lib/solid_queue/dispatcher/recurring_task.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def valid?
4242
end
4343

4444
def to_s
45-
"#{class_name}.perform_later(#{arguments.map(&:inspect).join(",")}) [ #{parsed_schedule.original.to_s} ]"
45+
"#{class_name}.perform_later(#{arguments.map(&:inspect).join(",")}) [ #{parsed_schedule.original} ]"
4646
end
4747

4848
def to_h
@@ -82,4 +82,4 @@ def job_class
8282
@job_class ||= class_name.safe_constantize
8383
end
8484
end
85-
end
85+
end

lib/solid_queue/engine.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Engine < ::Rails::Engine
1818

1919
initializer "solid_queue.app_executor", before: :run_prepare_callbacks do |app|
2020
config.solid_queue.app_executor ||= app.executor
21-
config.solid_queue.on_thread_error ||= -> (exception) { Rails.error.report(exception, handled: false) }
21+
config.solid_queue.on_thread_error ||= ->(exception) { Rails.error.report(exception, handled: false) }
2222

2323
SolidQueue.app_executor = config.solid_queue.app_executor
2424
SolidQueue.on_thread_error = config.solid_queue.on_thread_error

lib/solid_queue/processes/interruptible.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def wake_up
1010
SELF_PIPE_BLOCK_SIZE = 11
1111

1212
def interrupt
13-
self_pipe[:writer].write_nonblock( "." )
13+
self_pipe[:writer].write_nonblock(".")
1414
rescue Errno::EAGAIN, Errno::EINTR
1515
# Ignore writes that would block and retry
1616
# if another signal arrived while writing

solid_queue.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
2323
spec.add_dependency "railties", rails_version
2424
spec.add_dependency "concurrent-ruby", "~> 1.2.2"
2525
spec.add_dependency "fugit", "~> 1.9.0"
26+
2627
spec.add_development_dependency "debug"
2728
spec.add_development_dependency "mocha"
2829
spec.add_development_dependency "puma"
2930
spec.add_development_dependency "mysql2"
3031
spec.add_development_dependency "pg"
3132
spec.add_development_dependency "sqlite3"
33+
spec.add_development_dependency "rubocop-rails-omakase"
3234
end

test/integration/concurrency_controls_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "test_helper"
34

45
class ConcurrencyControlsTest < ActiveSupport::TestCase
@@ -184,7 +185,7 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase
184185

185186
private
186187
def assert_stored_sequence(result, *sequences)
187-
expected = sequences.map { |sequence| "seq: " + sequence.map { |name| "s#{name}c#{name}"}.join }
188+
expected = sequences.map { |sequence| "seq: " + sequence.map { |name| "s#{name}c#{name}" }.join }
188189
skip_active_record_query_cache do
189190
assert_includes expected, result.reload.status
190191
end

test/integration/jobs_lifecycle_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "test_helper"
34

45
class JobsLifecycleTest < ActiveSupport::TestCase
@@ -133,7 +134,7 @@ class JobsLifecycleTest < ActiveSupport::TestCase
133134
SolidQueue::Job.clear_finished_in_batches
134135
end
135136
end
136-
137+
137138
test "respect class name when clearing finished jobs" do
138139
10.times { AddToBufferJob.perform_later(2) }
139140
10.times { RaisingJob.perform_later(RuntimeError, "A") }

test/integration/puma/plugin_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "test_helper"
34

45
class PumaPluginTest < ActiveSupport::TestCase
@@ -7,7 +8,7 @@ class PumaPluginTest < ActiveSupport::TestCase
78
setup do
89
FileUtils.mkdir_p Rails.root.join("tmp", "pids")
910

10-
Dir.chdir('test/dummy') do
11+
Dir.chdir("test/dummy") do
1112
cmd = %w[
1213
bundle exec puma
1314
-b tcp://127.0.0.1:9222

test/integration/recurring_tasks_test.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require "test_helper"
34

45
class RecurringTasksTest < ActiveSupport::TestCase

test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ENV["RAILS_ENV"] = "test"
33

44
require_relative "../test/dummy/config/environment"
5-
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
5+
ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ]
66
require "rails/test_help"
77
require "debug"
88
require "mocha/minitest"

0 commit comments

Comments
 (0)