skandragon/thing

View on GitHub
app/models/instructable.rb

Summary

Maintainability
D
2 days
Test Coverage

Method check_for_proofread_changes has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

  def check_for_proofread_changes
    return true if @is_proofreader and @is_proofreader == :no_really

    needs_clearing = false
    changes.keys.each do |field_name|
Severity: Minor
Found in app/models/instructable.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

File instructable.rb has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Instructable < ApplicationRecord
  belongs_to :user
  has_many :instances, -> { order('start_time, location') }, dependent: :destroy
  has_many :changelogs, as: :target
  accepts_nested_attributes_for :instances, allow_destroy: true
Severity: Minor
Found in app/models/instructable.rb - About 5 hrs to fix

    Class Instructable has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Instructable < ApplicationRecord
      belongs_to :user
      has_many :instances, -> { order('start_time, location') }, dependent: :destroy
      has_many :changelogs, as: :target
      accepts_nested_attributes_for :instances, allow_destroy: true
    Severity: Minor
    Found in app/models/instructable.rb - About 3 hrs to fix

      Method check_for_proofread_changes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check_for_proofread_changes
          return true if @is_proofreader and @is_proofreader == :no_really
      
          needs_clearing = false
          changes.keys.each do |field_name|
      Severity: Minor
      Found in app/models/instructable.rb - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    update_column(:proofread, true) unless proofread
        Severity: Major
        Found in app/models/instructable.rb - About 45 mins to fix

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

            def formatted_nontrack_location
              raise Exception.new("location_type is 'track' but no location known") unless location_nontrack?
              if location_type == 'private-camp'
                ret = [camp_name]
                ret << "(#{camp_address})" if camp_address.present?
          Severity: Minor
          Found in app/models/instructable.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

          Method locations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.locations(filter = nil)
              filter = Array(filter) unless filter.nil?
              ret = {}
              TRACKS.each do |track, locations|
                if filter.nil? or filter.include?(track)
          Severity: Minor
          Found in app/models/instructable.rb - About 25 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 check_fees_for_zero has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_fees_for_zero
              if handout_fee.present?
                self.handout_fee = nil if handout_fee.to_f == 0.0
              end
              if material_fee.present?
          Severity: Minor
          Found in app/models/instructable.rb - About 25 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