app/models/job.rb

Summary

Maintainability
C
1 day
Test Coverage

Method find_jobs has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_jobs(user, occur_start, occur_end, tags, incexc, enabled, succeeded, running, name, timezone, command)
    search = Job.mine(user)
    search = search.enabled(enabled) unless enabled.nil?
    search = search.running(running) unless running.nil?
    search = search.successful(succeeded) unless succeeded.nil?
Severity: Minor
Found in app/models/job.rb - About 3 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 search_jobs has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.search_jobs(user, expression)
    tags = nil
    enabled = nil
    succeeded = nil
    running = nil
Severity: Major
Found in app/models/job.rb - About 2 hrs to fix

    Method find_jobs has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.find_jobs(user, occur_start, occur_end, tags, incexc, enabled, succeeded, running, name, timezone, command)
    Severity: Major
    Found in app/models/job.rb - About 1 hr to fix

      Method search_jobs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.search_jobs(user, expression)
          tags = nil
          enabled = nil
          succeeded = nil
          running = nil
      Severity: Minor
      Found in app/models/job.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 filter_runs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def filter_runs(start_dt, end_dt, success)
          start_dt = Chronic.parse(start_dt) unless start_dt.blank?
          end_dt = Chronic.parse(end_dt) unless end_dt.blank?
      
          query = job_runs
      Severity: Minor
      Found in app/models/job.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 stop_job has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def stop_job(run, return_code, success, error_message, stdout, stderr)
      Severity: Minor
      Found in app/models/job.rb - About 45 mins to fix

        Method compute_run_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def compute_run_stats
            job_runtimes = JobRun.job_runtimes(id)
        
            avg_runtime = JobRun.avg_runtime_for_job(id)
            max_runtime = JobRun.max_runtime_for_job(id)
        Severity: Minor
        Found in app/models/job.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

        There are no issues that match your filters.

        Category
        Status