Skip to content

Commit

Permalink
Bump rubocop (#539)
Browse files Browse the repository at this point in the history
* Bump rubocop

* Bump appraisals

* Run spec for known to be supported sidekiq version
  • Loading branch information
mhenrixon authored Oct 26, 2020
1 parent 4d6e1f6 commit 9a6062d
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 29 deletions.
16 changes: 13 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ inherit_gem:
- config/default.yml

AllCops:
TargetRubyVersion: 2.5
NewCops: enable
TargetRubyVersion: 2.5
Include:
- "examples/**/*.rb"
Exclude:
Expand Down Expand Up @@ -64,6 +64,17 @@ Naming/MethodParameterName:
AllowedNames:
- ex

RSpec/ContextWording:
Enabled: true
Prefixes:
- when
- with
- without
- if
- unless
- for
- that

RSpec/DescribeClass:
Exclude:
- spec/sidekiq/api_spec.rb
Expand Down Expand Up @@ -97,8 +108,7 @@ RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/NestedGroups:
Max: 4
Enabled: true
Max: 5

RSpec/RepeatedExample:
Exclude:
Expand Down
3 changes: 1 addition & 2 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "simplecov-material"
require "simplecov-oj"

SimpleCov.command_name "RSpec"
# SimpleCov.refuse_coverage_drop
SimpleCov.formatters = [
SimpleCov::Formatter::MaterialFormatter,
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::OjFormatter,
]

Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end

def changed_files(pedantry)
`git diff-tree --no-commit-id --name-only -r HEAD~#{pedantry} HEAD`
.split("\n").select { |f| f.match(/(\.rb\z)|Rakefile/) && File.exist?(f) && f.include?(db) }
.split("\n").select { |f| f.match(/(\.rb\z)|Rakefile/) && File.exist?(f) && !f.include?("db") }
end

RuboCop::RakeTask.new(:rubocop) do |task|
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_4.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_4.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_5.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_5.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
1 change: 0 additions & 1 deletion gemfiles/sidekiq_develop.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ platforms :mri do
gem "rspec-benchmark"
gem "rubocop-mhenrixon"
gem "simplecov", "< 0.18"
gem "simplecov-material"
gem "simplecov-oj"
gem "travis"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/sidekiq_unique_jobs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ module SidekiqUniqueJobs
#
class Cli < Thor
# :nodoc:
# rubocop:disable Style/OptionalBooleanParameter
def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
"jobs #{@package_name} #{command.usage}" # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
end
# rubocop:enable Style/OptionalBooleanParameter

desc "list PATTERN", "list all unique digests and their expiry time"
option :count, aliases: :c, type: :numeric, default: 1000, desc: "The max number of digests to return"
Expand Down
9 changes: 6 additions & 3 deletions myapp/bin/check_or_setup_db
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ rescue ActiveRecord::NoDatabaseError, ActiveRecord::AdapterNotSpecified
ActiveSupport::Dependencies.autoload_paths << File.join(DatabaseTasks.root, "app", "models", "concerns")
ActiveSupport::Dependencies.autoload_paths << File.join(DatabaseTasks.root, "app", "models")

exit 2 unless DatabaseTasks.create_current
exit 3 unless DatabaseTasks.load_schema_current
exit 4 unless DatabaseTasks.load_seed
# rubocop:disable Lint/TopLevelReturnWithArgument
return 2 unless DatabaseTasks.create_current
return 3 unless DatabaseTasks.load_schema_current
return 4 unless DatabaseTasks.load_seed

# rubocop:enable Lint/TopLevelReturnWithArgument

0
ensure
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:item) do
{ "class" => "JustAWorker",
"queue" => "testqueue",
"args" => [foo: "bar"] }
"args" => [{ foo: "bar" }] }
end
let(:lock_digest) { "uniquejobs:577db3c4fc72230bf2c256faa708a083" }
let(:key) { SidekiqUniqueJobs::Key.new(lock_digest) }
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/lock/base_lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{ "class" => "JustAWorker",
"queue" => "testqueue",
"on_conflict" => strategy,
"args" => [foo: "bar"] }
"args" => [{ foo: "bar" }] }
end

describe "#execute" do
Expand Down
2 changes: 0 additions & 2 deletions spec/sidekiq_unique_jobs/lock_timeout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@
context "with global config", :with_global_config do
let(:global_config) { { lock_timeout: 66 } }

# rubocop:disable RSpec/NestedGroups
context "with worker options", :with_worker_options do
let(:worker_options) { { lock_timeout: 33 } }

it { is_expected.to eq(33) }
end
# rubocop:enable RSpec/NestedGroups
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/sidekiq_unique_jobs/normalizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
RSpec.describe SidekiqUniqueJobs::Normalizer do
describe ".jsonify" do
specify do
original = [1, :test, [test: :test]]
expected = [1, "test", ["test" => "test"]]
original = [1, :test, [{ test: :test }]]
expected = [1, "test", [{ "test" => "test" }]]
expect(described_class.jsonify(original)).to eq(expected)
end

specify do
original = [1, :test, [test: [test: :test]]]
expected = [1, "test", ["test" => ["test" => "test"]]]
original = [1, :test, [{ test: [{ test: :test }] }]]
expected = [1, "test", [{ "test" => [{ "test" => "test" }] }]]
expect(described_class.jsonify(original)).to eq(expected)
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/sidekiq_unique_jobs/orphans/reaper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
end
end

context "that matches current digest" do
# TODO: Adjust this spec for earlier sidekiq versions
context "that matches current digest", sidekiq_ver: ">= 6.0" do
it "keeps the digest" do
expect { call }.not_to change { digests.count }.from(1)
expect(unique_keys).not_to match_array([])
Expand Down
2 changes: 1 addition & 1 deletion spec/support/ruby_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.configure do |config|
config.before do |example|
if (ruby_ver = example.metadata[:ruby_ver])
if SidekiqUniqueJobs::VersionCheck.unfulfilled?(RUBY_VERSION, ruby_ver) # rubocop:disable Style/SoleNestedConditional
unless SidekiqUniqueJobs::VersionCheck.satisfied?(RUBY_VERSION, ruby_ver) # rubocop:disable Style/SoleNestedConditional
skip("Ruby (#{RUBY_VERSION}) should be #{ruby_ver}")
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/sidekiq_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def sidekiq_redis_driver
end

if (sidekiq_ver = example.metadata[:sidekiq_ver])
if SidekiqUniqueJobs::VersionCheck.unfulfilled?(Sidekiq::VERSION, sidekiq_ver) # rubocop:disable Style/SoleNestedConditional
unless SidekiqUniqueJobs::VersionCheck.satisfied?(Sidekiq::VERSION, sidekiq_ver) # rubocop:disable Style/SoleNestedConditional
skip("Sidekiq (#{Sidekiq::VERSION}) should be #{sidekiq_ver}")
end
end
Expand Down

0 comments on commit 9a6062d

Please sign in to comment.