mhenrixon/sidekiq-unique-jobs

View on GitHub

Showing 19 of 32,162 total issues

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

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

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

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

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

Method registered has a Cognitive Complexity of 8 (exceeds 5 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: Minor
Found in lib/sidekiq_unique_jobs/web.rb - About 45 mins 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 constantize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def constantize(str)
    return str.class             if str.is_a?(Sidekiq::Job) # sidekiq v6.x
    return str                   unless str.is_a?(String)
    return Object.const_get(str) unless str.include?("::")

Severity: Minor
Found in lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb - About 35 mins 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 enqueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def enqueue(conn)
      queued_jid, elapsed = timed do
        call_script(:queue, key.to_a, argv, conn)
      end

Severity: Minor
Found in lib/sidekiq_unique_jobs/locksmith.rb - About 35 mins 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 logging_context has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def logging_context
        middleware = is_a?(SidekiqUniqueJobs::Middleware::Client) ? :client : :server
        digest     = item[LOCK_DIGEST]
        lock_type  = item[LOCK]

Severity: Minor
Found in lib/sidekiq_unique_jobs/logging/middleware_context.rb - About 25 mins 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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def execute
      synchronize do
        if @running.false?
          @running.make_true
          schedule_next_task(@run_now ? 0 : @execution_interval)
Severity: Minor
Found in lib/sidekiq_unique_jobs/timer_task.rb - About 25 mins 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 lock_args_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def lock_args_method
      @lock_args_method ||= job_options.slice(LOCK_ARGS_METHOD, UNIQUE_ARGS_METHOD).values.first
      @lock_args_method ||= :lock_args if job_method_defined?(:lock_args)
      @lock_args_method ||= :unique_args if job_method_defined?(:unique_args)
      @lock_args_method ||= default_lock_args_method
Severity: Minor
Found in lib/sidekiq_unique_jobs/lock_args.rb - About 25 mins 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 scripts_path= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def scripts_path=(obj)
        raise ArgumentError, "#{obj} should be a Pathname or String" unless obj.is_a?(Pathname) || obj.is_a?(String)
        raise ArgumentError, "#{obj} does not exist" unless Dir.exist?(obj.to_s)

        @scripts_path =
Severity: Minor
Found in lib/sidekiq_unique_jobs/script/config.rb - About 25 mins 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 delete_by_digest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def delete_by_digest(digest, queuetime: true, runtime: true)
      result, elapsed = timed do
        call_script(
          :delete_by_digest,
          queuetime_keys(queuetime ? digest : nil) + runtime_keys(runtime ? digest : nil) + [key],
Severity: Minor
Found in lib/sidekiq_unique_jobs/digests.rb - About 25 mins 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

Severity
Category
Status
Source
Language