Skip to content

Add rubocop-rails-omakase and fix flagged problems #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ name: Build
on: [push, pull_request]

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- name: Run rubocop
run: |
bundle exec rubocop --parallel
tests:
name: Tests
runs-on: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Want to disable a check for a specific case? To disable checks inline:
# http://docs.rubocop.org/en/latest/configuration/#disabling-cops-within-source-code

inherit_gem: { rubocop-rails-omakase: rubocop.yml }

AllCops:
TargetRubyVersion: 3.0
Exclude:
- "test/dummy/db/schema.rb"
42 changes: 42 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
builder (3.2.4)
Expand All @@ -69,6 +70,8 @@ GEM
io-console (0.6.0)
irb (1.6.2)
reline (>= 0.3.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -85,6 +88,10 @@ GEM
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pg (1.5.4)
puma (6.4.2)
nio4r (~> 2.0)
Expand Down Expand Up @@ -113,16 +120,50 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.9.0)
reline (0.3.2)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.24.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sqlite3 (1.5.4)
mini_portile2 (~> 2.8.0)
thor (1.2.2)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
zeitwerk (2.6.12)

Expand All @@ -138,6 +179,7 @@ DEPENDENCIES
mysql2
pg
puma
rubocop-rails-omakase
solid_queue!
sqlite3

Expand Down
2 changes: 1 addition & 1 deletion app/models/solid_queue/failed_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def expand_error_details_from_exception
self.error = { exception_class: exception.class.name, message: exception.message, backtrace: exception.backtrace }
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/solid_queue/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def set_procline
end

def metadata
super.merge(batch_size: batch_size, concurrency_maintenance_interval: concurrency_maintenance&.interval, recurring_schedule: recurring_schedule.tasks.presence )
super.merge(batch_size: batch_size, concurrency_maintenance_interval: concurrency_maintenance&.interval, recurring_schedule: recurring_schedule.tasks.presence)
end
end
end
4 changes: 2 additions & 2 deletions lib/solid_queue/dispatcher/recurring_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def valid?
end

def to_s
"#{class_name}.perform_later(#{arguments.map(&:inspect).join(",")}) [ #{parsed_schedule.original.to_s} ]"
"#{class_name}.perform_later(#{arguments.map(&:inspect).join(",")}) [ #{parsed_schedule.original} ]"
end

def to_h
Expand Down Expand Up @@ -82,4 +82,4 @@ def job_class
@job_class ||= class_name.safe_constantize
end
end
end
end
2 changes: 1 addition & 1 deletion lib/solid_queue/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Engine < ::Rails::Engine

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

SolidQueue.app_executor = config.solid_queue.app_executor
SolidQueue.on_thread_error = config.solid_queue.on_thread_error
Expand Down
2 changes: 1 addition & 1 deletion lib/solid_queue/processes/interruptible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def wake_up
SELF_PIPE_BLOCK_SIZE = 11

def interrupt
self_pipe[:writer].write_nonblock( "." )
self_pipe[:writer].write_nonblock(".")
rescue Errno::EAGAIN, Errno::EINTR
# Ignore writes that would block and retry
# if another signal arrived while writing
Expand Down
2 changes: 2 additions & 0 deletions solid_queue.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
spec.add_dependency "railties", rails_version
spec.add_dependency "concurrent-ruby", "~> 1.2.2"
spec.add_dependency "fugit", "~> 1.9.0"

spec.add_development_dependency "debug"
spec.add_development_dependency "mocha"
spec.add_development_dependency "puma"
spec.add_development_dependency "mysql2"
spec.add_development_dependency "pg"
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "rubocop-rails-omakase"
end
3 changes: 2 additions & 1 deletion test/integration/concurrency_controls_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class ConcurrencyControlsTest < ActiveSupport::TestCase
Expand Down Expand Up @@ -184,7 +185,7 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase

private
def assert_stored_sequence(result, *sequences)
expected = sequences.map { |sequence| "seq: " + sequence.map { |name| "s#{name}c#{name}"}.join }
expected = sequences.map { |sequence| "seq: " + sequence.map { |name| "s#{name}c#{name}" }.join }
skip_active_record_query_cache do
assert_includes expected, result.reload.status
end
Expand Down
3 changes: 2 additions & 1 deletion test/integration/jobs_lifecycle_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class JobsLifecycleTest < ActiveSupport::TestCase
Expand Down Expand Up @@ -133,7 +134,7 @@ class JobsLifecycleTest < ActiveSupport::TestCase
SolidQueue::Job.clear_finished_in_batches
end
end

test "respect class name when clearing finished jobs" do
10.times { AddToBufferJob.perform_later(2) }
10.times { RaisingJob.perform_later(RuntimeError, "A") }
Expand Down
3 changes: 2 additions & 1 deletion test/integration/puma/plugin_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"

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

Dir.chdir('test/dummy') do
Dir.chdir("test/dummy") do
cmd = %w[
bundle exec puma
-b tcp://127.0.0.1:9222
Expand Down
1 change: 1 addition & 0 deletions test/integration/recurring_tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"

class RecurringTasksTest < ActiveSupport::TestCase
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ENV["RAILS_ENV"] = "test"

require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ]
require "rails/test_help"
require "debug"
require "mocha/minitest"
Expand Down
Loading