nathan-v/resque-state

View on GitHub

Showing 8 of 8 total issues

Class Hash has 45 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Hash < ::Hash
        # Create a status, a new UUID, passing the message to the status
        # Returns the UUID of the new status.
        def self.create(uuid, *messages)
          set(uuid, *messages)
Severity: Minor
Found in lib/resque/plugins/state/hash.rb - About 6 hrs to fix

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

        def self.registered(app)
          app.get '/state' do
            @start = params[:start].to_i
            @end = @start + (params[:per_page] || per_page) - 1
            @statuses = Resque::Plugins::State::Hash.statuses(@start, @end)
    Severity: Major
    Found in lib/resque/state_server.rb - About 2 hrs to fix

      Method safe_perform! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def safe_perform!
              job_status('status' => STATUS_WORKING)
              messages = ['Job starting']
              @logger.info("#{@uuid}: #{messages.join(' ')}")
              perform
      Severity: Minor
      Found in lib/resque/plugins/state.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def lock!(key = nil)
              lock = Digest::SHA1.hexdigest @options.to_json
              lock = key if key
              if locked?(lock)
                messages = ["Waiting at #{Time.now} due to existing job"]
      Severity: Minor
      Found in lib/resque/plugins/state.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 safe_perform! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def safe_perform!
              job_status('status' => STATUS_WORKING)
              messages = ['Job starting']
              @logger.info("#{@uuid}: #{messages.join(' ')}")
              perform
      Severity: Minor
      Found in lib/resque/plugins/state.rb - About 1 hr to fix

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

                def pct_complete
                  if completed?
                    100
                  elsif queued?
                    0
        Severity: Minor
        Found in lib/resque/plugins/state/hash.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 tick has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def tick(*messages)
                kill! if should_kill?
                if should_pause?
                  pause!
                elsif should_revert?
        Severity: Minor
        Found in lib/resque/plugins/state.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 pause! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def pause!(pause_text = nil)
                Resque::Plugins::State::Hash.pause(uuid)
                messages = ["Paused at #{Time.now} #{pause_text}"]
                job_status('status' => STATUS_PAUSED,
                           'message' => messages[0])
        Severity: Minor
        Found in lib/resque/plugins/state.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