Showing 15 of 19 total issues

Method todays_stats has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.todays_stats(user)
    stats = JobStat.minutely_today(user).order(created_at: :asc)
    total_jobs_array = stats.collect { |stat| stat.total_jobs || 0 }
    enabled_jobs_array = stats.collect { |stat| stat.total_enabled || 0 }
    run_jobs_array = stats.collect { |stat| stat.runs || 0 }
Severity: Minor
Found in app/models/job_stat.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 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 update has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @job.name = params[:name] unless (@job.name == params[:name]) || params[:name].blank?
    @job.cron = params[:cron] unless (@job.cron == params[:cron]) || params[:cron].blank?
    @job.command = params[:command] unless (@job.command == params[:command]) || params[:command].blank?
    @job.timezone = params[:timezone] unless (@job.timezone == params[:timezone]) || params[:timezone].blank?
Severity: Minor
Found in app/controllers/job_api_controller.rb - About 2 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 todays_stats has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.todays_stats(user)
        stats = JobStat.minutely_today(user).order(created_at: :asc)
        total_jobs_array = stats.collect { |stat| stat.total_jobs || 0 }
        enabled_jobs_array = stats.collect { |stat| stat.total_enabled || 0 }
        run_jobs_array = stats.collect { |stat| stat.runs || 0 }
    Severity: Minor
    Found in app/models/job_stat.rb - About 1 hr 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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @folder.name = params[:name] unless (@folder.name == params[:name]) || params[:name].blank?
            @folder.expression = params[:expression] unless (@folder.expression == params[:expression]) || params[:expression].blank?
            @folder.save!
            message I18n.t('folders.messages.updated', id: @folder.id), :ok, false, @folder, 'folder'
        Severity: Minor
        Found in app/controllers/folder_api_controller.rb - About 55 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 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 message has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def message(message, status, is_error = false, object = {}, object_type = '')
          Severity: Minor
          Found in app/controllers/application_controller.rb - About 35 mins to fix

            Method update_run has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def update_run(return_code, success, error_message, stdout, stderr)
            Severity: Minor
            Found in app/models/job_run.rb - About 35 mins to fix

              Method iterate_over_ranges has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def iterate_over_ranges(user, period, stat_start_dt, time_incr, end_dt)
              Severity: Minor
              Found in app/jobs/base_stats_job.rb - About 35 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

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

                  def update_run(return_code, success, error_message, stdout, stderr)
                    self.success = success
                    self.return_code = return_code
                    self.error_message = error_message
                    self.stdout = stdout.nil? ? '' : stdout.encode('UTF-8', invalid: :replace, undef: :replace)
                Severity: Minor
                Found in app/models/job_run.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