cblavier/jobbr

View on GitHub

Showing 3 of 3 total issues

Class Job has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Job < ::Ohm::Model

    MAX_RUN_PER_JOB = 500

    include ::Ohm::Timestamps
Severity: Minor
Found in app/models/jobbr/job.rb - About 3 hrs to fix

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

        def run(params = {}, options = {})
          options = { delayed: true }.merge(options)
          job_run = Run.create(status: :waiting, started_at: Time.now, job: self)
          if options[:delayed] && self.delayed && !Rails.env.test? && !Rails.env.ci?
            delayed_options = { retry: 0, backtrace: true }
    Severity: Minor
    Found in app/models/jobbr/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 display_scheduling has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_scheduling(job)
          every = job.every
          if every
            scheduling = every[0].is_a?(Fixnum) ? ChronicDuration.output(every[0]) : every[0].to_s
            if every[1] && !every[1].empty?
    Severity: Minor
    Found in app/helpers/jobbr/application_helper.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