tobiassvn/sidetiq

View on GitHub

Showing 4 of 4 total issues

Method registered has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.registered(app)
      app.get "/sidetiq" do
        @workers = Sidetiq.workers.sort_by { |worker| worker.name }
        @time = Sidetiq.clock.gettime
        erb File.read(File.join(VIEWS, 'sidetiq.erb')), locals: {view_path: VIEWS}
Severity: Minor
Found in lib/sidetiq/web.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

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

    def self.registered(app)
      app.get "/sidetiq" do
        @workers = Sidetiq.workers.sort_by { |worker| worker.name }
        @time = Sidetiq.clock.gettime
        erb File.read(File.join(VIEWS, 'sidetiq.erb')), locals: {view_path: VIEWS}
Severity: Major
Found in lib/sidetiq/web.rb - About 2 hrs to fix

    Method dispatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def dispatch(worker, tick)
          schedule = worker.schedule
    
          return unless schedule.schedule_next?(tick)
    
    
    Severity: Minor
    Found in lib/sidetiq/handler.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 enqueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def enqueue(worker, time, redis)
          key      = "sidetiq:#{worker.name}"
          time_f   = time.to_f
          next_run = (redis.get("#{key}:next") || -1).to_f
    
    
    Severity: Minor
    Found in lib/sidetiq/handler.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

    Severity
    Category
    Status
    Source
    Language