mhenrixon/sidekiq-unique-jobs

View on GitHub

Showing 32,162 of 32,162 total issues

Complex method SidekiqUniqueJobs::Web::registered (171.2)
Open

    def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
      app.helpers do
        include Web::Helpers
      end

Severity: Minor
Found in lib/sidekiq_unique_jobs/web.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method active? has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def active?(digest) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
        Sidekiq.redis do |conn|
          procs = conn.sscan("processes").to_a
          return false if procs.empty?

Severity: Minor
Found in lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Complex method LockSimulator#create_v7_locks (59.4)
Open

  def create_v7_locks(num = 20) # rubocop:disable Metrics/MethodLength
    old_digests = Array.new(num) { |n| "uniquejobs:v7-#{n}" }
    Sidekiq.redis do |conn| # rubocop:disable Metrics/BlockLength
      old_digests.each_slice(100) do |chunk|
        conn.pipelined do |pipeline|
Severity: Minor
Found in myapp/app/lib/lock_simulator.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Class Locksmith has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Locksmith # rubocop:disable Metrics/ClassLength
    # includes "SidekiqUniqueJobs::Connection"
    # @!parse include SidekiqUniqueJobs::Connection
    include SidekiqUniqueJobs::Connection

Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb - About 3 hrs to fix

File app.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {

var localStorage = {}, sessionStorage = {};
try { localStorage = window.localStorage; } catch (e) { }
try { sessionStorage = window.sessionStorage; } catch (e) { }
Severity: Minor
Found in doc/js/app.js - About 2 hrs to fix

Method registered has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.registered(app) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
      app.helpers do
        include Web::Helpers
      end

Severity: Major
Found in lib/sidekiq_unique_jobs/web.rb - About 2 hrs to fix

Class Lock has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Lock # rubocop:disable Metrics/ClassLength
    # includes "SidekiqUniqueJobs::Connection"
    # @!parse include SidekiqUniqueJobs::Connection
    include SidekiqUniqueJobs::Connection

Severity: Minor
Found in lib/sidekiq_unique_jobs/lock.rb - About 2 hrs to fix

Method orphans has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def orphans # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
        orphans = []
        page    = 0
        per     = reaper_count * 2
        results = digests.byscore(0, max_score, offset: page * per, count: (page + 1) * per)
Severity: Minor
Found in lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function generateTOC has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateTOC() {
  if ($('#filecontents').length === 0) return;
  var _toc = $('<ol class="top"></ol>');
  var show = false;
  var toc = _toc;
Severity: Major
Found in doc/js/app.js - About 2 hrs to fix

Complex method SidekiqUniqueJobs::Orphans::RubyReaper#orphans (39.6)
Open

      def orphans # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
        orphans = []
        page    = 0
        per     = reaper_count * 2
        results = digests.byscore(0, max_score, offset: page * per, count: (page + 1) * per)

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method SidekiqUniqueJobs::Orphans::RubyReaper#active? (34.8)
Open

      def active?(digest) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
        Sidekiq.redis do |conn|
          procs = conn.sscan("processes").to_a
          return false if procs.empty?

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Function constantSummaryToggle has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function constantSummaryToggle() {
  $('.constants_summary_toggle').click(function(e) {
    e.preventDefault();
    localStorage.summaryCollapsed = $(this).text();
    $('.constants_summary_toggle').each(function() {
Severity: Minor
Found in doc/js/app.js - About 1 hr to fix

Complex method create_table#users (32.4)
Open

  create_table "users", force: :cascade do |t|
    t.boolean "admin", default: false
    t.string "email", default: "", null: false
    t.string "encrypted_password", default: "", null: false
    t.string "reset_password_token"
Severity: Minor
Found in myapp/db/schema.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      app.get "/expiring_locks" do
        @filter         = h(params[:filter]) || "*"
        @filter         = "*" if @filter == ""
        @count          = h(params[:count] || 100).to_i
        @current_cursor = h(params[:cursor]).to_i
Severity: Major
Found in lib/sidekiq_unique_jobs/web.rb and 1 other location - About 1 hr to fix
lib/sidekiq_unique_jobs/web.rb on lines 35..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      app.get "/locks" do
        @filter         = h(params[:filter]) || "*"
        @filter         = "*" if @filter == ""
        @count          = h(params[:count] || 100).to_i
        @current_cursor = h(params[:cursor]).to_i
Severity: Major
Found in lib/sidekiq_unique_jobs/web.rb and 1 other location - About 1 hr to fix
lib/sidekiq_unique_jobs/web.rb on lines 51..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method after_unlock_hook has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def after_unlock_hook # rubocop:disable Metrics/MethodLength
      lambda do
        if @original_job_class.respond_to?(:after_unlock)
          # instance method in sidekiq v6
          if @original_job_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
Severity: Minor
Found in lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method create_v7_locks has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_v7_locks(num = 20) # rubocop:disable Metrics/MethodLength
    old_digests = Array.new(num) { |n| "uniquejobs:v7-#{n}" }
    Sidekiq.redis do |conn| # rubocop:disable Metrics/BlockLength
      old_digests.each_slice(100) do |chunk|
        conn.pipelined do |pipeline|
Severity: Minor
Found in myapp/app/lib/lock_simulator.rb - About 1 hr to fix

Complex method SidekiqUniqueJobs::Lock#lock (29.9)
Open

    def lock(job_id, lock_info = {}, score = nil)
      score ||= now_f
      redis do |conn|
        conn.multi do |pipeline|
          pipeline.set(key.digest, job_id)
Severity: Minor
Found in lib/sidekiq_unique_jobs/lock.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Function summaryToggle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function summaryToggle() {
  $('.summary_toggle').click(function(e) {
    e.preventDefault();
    localStorage.summaryCollapsed = $(this).text();
    $('.summary_toggle').each(function() {
Severity: Minor
Found in doc/js/app.js - About 1 hr to fix

Complex method DeviseCreateUsers#change (27.8)
Open

  def change
    create_table :users do |t|
      t.boolean :admin, default: false
      ## Database authenticatable
      t.string :email,              null: false, default: ""

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Severity
Category
Status
Source
Language