Showing 65 of 103 total issues
Method save_new_version?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_new_version?
return false unless content_type == 'note'
return false if external_updated_at_was.blank?
return false if external_updated_at == external_updated_at_was
NB.versions == 'true' && ((external_updated_at - external_updated_at_was) > NB.version_gap_minutes.to_i.minutes || get_real_distance > NB.version_gap_distance.to_i)
- Read upRead up
- Create a ticketCreate a ticket
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 show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
@notes = Note.publishable.where(feature: params[:feature], lang: I18n.locale)
if @notes.empty?
flash[:error] = "404 error! #{ request.url } does not exist."
- Read upRead up
- Create a ticketCreate a ticket
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 show_feature
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show_feature
@note = params[:feature_id].nil? ? @notes.first : @notes.where(feature_id: params[:feature_id]).first
note_tags(@note)
commontator_thread_show(@note)
@map = mapify(@note) if @note.has_instruction?('map') && !@note.inferred_latitude.nil?
- Read upRead up
- Create a ticketCreate a ticket
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 author_surname
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def author_surname
return nil if author.blank? && editor.blank?
surname = (author.blank? ? editor : author).split(',')[0].scan(/([^ ]*)$/)[0][0]
author.blank? ? "#{ surname } #{ I18n.t('books.show.editor_short') }" : surname
end
- Read upRead up
- Create a ticketCreate a ticket
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 make_local_file_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def make_local_file_name
if mime && mime !~ /image/
new_name = File.basename(file_name, File.extname(file_name))
elsif caption && !caption[/[a-zA-Z\-]{5,}/].blank? # Ensure caption is in Latin script and at least 5 characters
new_name = caption[0..NB.images_name_length.to_i]
- Read upRead up
- Create a ticketCreate a ticket
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"