QueueClassic/queue_classic

View on GitHub

Showing 5 of 10 total issues

Method lock has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def lock
      QC.log_yield(measure: 'queue.lock') do
        s = <<~SQL
          WITH selected_job AS (
            SELECT id
Severity: Minor
Found in lib/queue_classic/queue.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 lock has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def lock
      QC.log_yield(measure: 'queue.lock') do
        s = <<~SQL
          WITH selected_job AS (
            SELECT id
Severity: Minor
Found in lib/queue_classic/queue.rb - About 1 hr to fix

    Method enqueue_in has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def enqueue_in(seconds, method, *args)
          QC.log_yield(measure: 'queue.enqueue') do
            s = "INSERT INTO #{QC.table_name} (q_name, method, args, scheduled_at)
                 VALUES ($1, $2, $3, now() + interval '#{seconds.to_i} seconds')
                 RETURNING id"
    Severity: Minor
    Found in lib/queue_classic/queue.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 enqueue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def enqueue(method, *args)
          QC.log_yield(measure: 'queue.enqueue') do
            s = "INSERT INTO #{QC.table_name} (q_name, method, args) VALUES ($1, $2, $3) RETURNING id"
            begin
              retries ||= 0
    Severity: Minor
    Found in lib/queue_classic/queue.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute(stmt, *params)
          @mutex.synchronize do
            QC.log(at: 'exec_sql', sql: stmt.inspect)
            begin
              params = nil if params.empty?
    Severity: Minor
    Found in lib/queue_classic/conn_adapter.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