From 978ce8e6cf83edf601289cf5aedf45bb2996bcc8 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 28 Aug 2019 10:13:41 -0700 Subject: [PATCH] Update to latest standardrb, fix style issues --- .gitignore | 2 +- lib/sidekiq.rb | 2 +- lib/sidekiq/api.rb | 8 ++++---- lib/sidekiq/middleware/chain.rb | 2 +- lib/sidekiq/processor.rb | 2 +- lib/sidekiq/web/application.rb | 2 +- lib/sidekiq/web/helpers.rb | 2 +- sidekiq.gemspec | 20 ++++++++++---------- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index cf5f1d0c..270a49e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .rvmrc .ruby-version tags -gemfiles/*.lock +Gemfile.lock *.swp dump.rdb .rbx diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index f68f8ab0..b0ab162a 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -119,7 +119,7 @@ module Sidekiq end rescue Redis::CommandError => ex # 2850 return fake version when INFO command has (probably) been renamed - raise unless ex.message =~ /unknown command/ + raise unless /unknown command/.match?(ex.message) FAKE_INFO end end diff --git a/lib/sidekiq/api.rb b/lib/sidekiq/api.rb index fe3eba41..7e608632 100644 --- a/lib/sidekiq/api.rb +++ b/lib/sidekiq/api.rb @@ -93,7 +93,7 @@ module Sidekiq s = processes.size workers_size = pipe2_res[0...s].map(&:to_i).inject(0, &:+) - enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+) + enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+) default_queue_latency = if (entry = pipe1_res[6].first) job = begin @@ -122,7 +122,7 @@ module Sidekiq end def reset(*stats) - all = %w[failed processed] + all = %w[failed processed] stats = stats.empty? ? all : all & stats.flatten.compact.map(&:to_s) mset_args = [] @@ -274,7 +274,7 @@ module Sidekiq loop do range_start = page * page_size - deleted_size - range_end = range_start + page_size - 1 + range_end = range_start + page_size - 1 entries = Sidekiq.redis { |conn| conn.lrange @rname, range_start, range_end } @@ -563,7 +563,7 @@ module Sidekiq loop do range_start = page * page_size + offset_size - range_end = range_start + page_size - 1 + range_end = range_start + page_size - 1 elements = Sidekiq.redis { |conn| conn.zrange name, range_start, range_end, with_scores: true } diff --git a/lib/sidekiq/middleware/chain.rb b/lib/sidekiq/middleware/chain.rb index 4b9fd651..9a53f53e 100644 --- a/lib/sidekiq/middleware/chain.rb +++ b/lib/sidekiq/middleware/chain.rb @@ -140,7 +140,7 @@ module Sidekiq def initialize(klass, *args) @klass = klass - @args = args + @args = args end def make_new diff --git a/lib/sidekiq/processor.rb b/lib/sidekiq/processor.rb index c349da33..76d5225d 100644 --- a/lib/sidekiq/processor.rb +++ b/lib/sidekiq/processor.rb @@ -126,7 +126,7 @@ module Sidekiq # the Reloader. It handles code loading, db connection management, etc. # Effectively this block denotes a "unit of work" to Rails. @reloader.call do - klass = constantize(job_hash["class"]) + klass = constantize(job_hash["class"]) worker = klass.new worker.jid = job_hash["jid"] @retrier.local(worker, pristine, queue) do diff --git a/lib/sidekiq/web/application.rb b/lib/sidekiq/web/application.rb index d6986a44..435157d2 100644 --- a/lib/sidekiq/web/application.rb +++ b/lib/sidekiq/web/application.rb @@ -257,7 +257,7 @@ module Sidekiq get "/stats" do sidekiq_stats = Sidekiq::Stats.new - redis_stats = redis_info.select { |k, v| REDIS_KEYS.include? k } + redis_stats = redis_info.select { |k, v| REDIS_KEYS.include? k } json( sidekiq: { processed: sidekiq_stats.processed, diff --git a/lib/sidekiq/web/helpers.rb b/lib/sidekiq/web/helpers.rb index c0e9a8c2..cdb8b831 100644 --- a/lib/sidekiq/web/helpers.rb +++ b/lib/sidekiq/web/helpers.rb @@ -84,7 +84,7 @@ module Sidekiq languages = env["HTTP_ACCEPT_LANGUAGE"] languages.to_s.downcase.gsub(/\s+/, "").split(",").map { |language| locale, quality = language.split(";q=", 2) - locale = nil if locale == "*" # Ignore wildcards + locale = nil if locale == "*" # Ignore wildcards quality = quality ? quality.to_f : 1.0 [locale, quality] }.sort { |(_, left), (_, right)| diff --git a/sidekiq.gemspec b/sidekiq.gemspec index c093bc4f..574eceae 100644 --- a/sidekiq.gemspec +++ b/sidekiq.gemspec @@ -1,17 +1,17 @@ require_relative "lib/sidekiq/version" Gem::Specification.new do |gem| - gem.authors = ["Mike Perham"] - gem.email = ["mperham@gmail.com"] - gem.summary = "Simple, efficient background processing for Ruby" - gem.description = "Simple, efficient background processing for Ruby." - gem.homepage = "http://sidekiq.org" - gem.license = "LGPL-3.0" + gem.authors = ["Mike Perham"] + gem.email = ["mperham@gmail.com"] + gem.summary = "Simple, efficient background processing for Ruby" + gem.description = "Simple, efficient background processing for Ruby." + gem.homepage = "http://sidekiq.org" + gem.license = "LGPL-3.0" - gem.executables = ["sidekiq"] - gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n") - gem.name = "sidekiq" - gem.version = Sidekiq::VERSION + gem.executables = ["sidekiq"] + gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n") + gem.name = "sidekiq" + gem.version = Sidekiq::VERSION gem.required_ruby_version = ">= 2.5.0" gem.add_dependency "redis", ">= 4.1.0"