diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..24525e4d9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint +on: [push] +jobs: + rubocop: + runs-on: ubuntu-latest + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - run: bundle install --jobs=$(nproc) --retry=$(nproc) + - run: bin/rubocop -P + + reek: + runs-on: ubuntu-latest + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - run: bundle install --jobs=$(nproc) --retry=$(nproc) + - run: bin/reek . diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml new file mode 100644 index 000000000..44fb37eb0 --- /dev/null +++ b/.github/workflows/rspec.yml @@ -0,0 +1,29 @@ +name: RSpec +on: [push] +jobs: + tests: + env: + COV: false + + services: + redis: + image: redis:latest + ports: + - 6379:6379 + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + # ruby: [2.5, 2.6, 2.7, jruby, truffleruby] + ruby: [2.5, 2.6, 2.7] + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - run: bundle install --jobs=$(nproc) --retry=$(nproc) + - run: bundle exec appraisal install --jobs=$(nproc) --retry=$(nproc) + - run: bundle exec appraisal rspec --require spec_helper --tag ~perf diff --git a/lib/sidekiq_unique_jobs/config.rb b/lib/sidekiq_unique_jobs/config.rb index 67f07c54e..c16993b80 100644 --- a/lib/sidekiq_unique_jobs/config.rb +++ b/lib/sidekiq_unique_jobs/config.rb @@ -185,25 +185,29 @@ def self.default # rubocop:disable Metrics/MethodLength end def default_lock_ttl=(obj) - warn "[DEPRECATION] `#{self.class}##{__method__}` is deprecated. Please use `#{self.class}#lock_ttl=` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. Please use `#{class_name}#lock_ttl=` instead." self.lock_ttl = obj end def default_lock_timeout=(obj) - warn "[DEPRECATION] `#{self.class}##{__method__}` is deprecated. Please use `#{self.class}#lock_timeout=` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. Please use `#{class_name}#lock_timeout=` instead." self.lock_timeout = obj end def default_lock_ttl - warn "[DEPRECATION] `#{self.class}##{__method__}` is deprecated. Please use `#{self.class}#lock_ttl` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. Please use `#{class_name}#lock_ttl` instead." lock_ttl end def default_lock_timeout - warn "[DEPRECATION] `#{self.class}##{__method__}` is deprecated. Please use `#{self.class}#lock_timeout` instead." + warn "[DEPRECATION] `#{class_name}##{__method__}` is deprecated. Please use `#{class_name}#lock_timeout` instead." lock_timeout end + def class_name + @class_name ||= self.class.name + end + # # Adds a lock type to the configuration. It will raise if the lock exists already # diff --git a/lib/sidekiq_unique_jobs/core_ext.rb b/lib/sidekiq_unique_jobs/core_ext.rb index f192dbc24..ca0e3d6e3 100644 --- a/lib/sidekiq_unique_jobs/core_ext.rb +++ b/lib/sidekiq_unique_jobs/core_ext.rb @@ -102,7 +102,7 @@ def _deep_transform_keys_in_object(object, &block) result[yield(key)] = _deep_transform_keys_in_object(value, &block) end when Array - object.map { |e| _deep_transform_keys_in_object(e, &block) } + object.map { |element| _deep_transform_keys_in_object(element, &block) } else object end