QutBioacoustics/baw-server

View on GitHub
lib/gems/baw-workers/lib/baw_workers/active_job/status.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

      def safe_perform!(&block)
        update_status(status: STATUS_WORKING)

        kill! if should_kill?

Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/active_job/status.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 update_status has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def update_status(*messages, status: nil, progress: nil, total: nil)
        ensure_status

        status ||= @status.status
        unless TERMINAL_STATUSES.include?(status) || status == STATUS_WORKING
Severity: Minor
Found in lib/gems/baw-workers/lib/baw_workers/active_job/status.rb - About 1 hr to fix

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

          def update_status(*messages, status: nil, progress: nil, total: nil)
            ensure_status
    
            status ||= @status.status
            unless TERMINAL_STATUSES.include?(status) || status == STATUS_WORKING
    Severity: Minor
    Found in lib/gems/baw-workers/lib/baw_workers/active_job/status.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

    There are no issues that match your filters.

    Category
    Status