openjaf/cenit

View on GitHub
app/models/setup/task.rb

Summary

Maintainability
D
3 days
Test Coverage

Class Task has 49 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Task
    include CenitScoped
    include ClassHierarchyAware
    include CrossOrigin::CenitDocument
    include FieldsInspection
Severity: Minor
Found in app/models/setup/task.rb - About 6 hrs to fix

    File task.rb has 423 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Setup
      class Task
        include CenitScoped
        include ClassHierarchyAware
        include CrossOrigin::CenitDocument
    Severity: Minor
    Found in app/models/setup/task.rb - About 6 hrs to fix

      Method execute has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute(options = {})
            task_desc = description.presence || "Task ##{id}"
            if running? || !Cenit::Locker.lock(self)
              notify(message: "Executing task ##{id} at #{Time.now} but it is already running")
            else
      Severity: Minor
      Found in app/models/setup/task.rb - About 5 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 execute has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def execute(options = {})
            task_desc = description.presence || "Task ##{id}"
            if running? || !Cenit::Locker.lock(self)
              notify(message: "Executing task ##{id} at #{Time.now} but it is already running")
            else
      Severity: Major
      Found in app/models/setup/task.rb - About 3 hrs to fix

        Method finish has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def finish(status, message, message_type, time)
              self.status = status
              thread_token.destroy if thread_token.present?
              self.thread_token = nil
              Thread.current[:task_token] = nil
        Severity: Minor
        Found in app/models/setup/task.rb - About 1 hr to fix

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

              def finish(status, message, message_type, time)
                self.status = status
                thread_token.destroy if thread_token.present?
                self.thread_token = nil
                Thread.current[:task_token] = nil
          Severity: Minor
          Found in app/models/setup/task.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

          There are no issues that match your filters.

          Category
          Status