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|
- Read upRead up
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
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
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|
Avoid deeply nested control flow statements. Open
update_column(:proofread, true) unless proofread
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?
- Read upRead up
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)
- Read upRead up
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?
- Read upRead up
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"