joegattnet/joegattnet_v3

View on GitHub
app/models/note.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Note has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

class Note < ActiveRecord::Base
  include NoteCustom, Syncable

  attr_writer :tag_list, :instruction_list, :keyword_list
  attr_accessor :external_created_at
Severity: Major
Found in app/models/note.rb - About 7 hrs to fix

File note.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Note < ActiveRecord::Base
  include NoteCustom, Syncable

  attr_writer :tag_list, :instruction_list, :keyword_list
  attr_accessor :external_created_at
Severity: Minor
Found in app/models/note.rb - About 3 hrs to fix

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

  def discard_versions?
    if has_instruction?('reset')
      self.external_updated_at = external_created_at if NB.always_reset_on_create == 'true'
      versions.destroy_all unless versions.empty?
    end
Severity: Minor
Found in app/models/note.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 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)
Severity: Minor
Found in app/models/note.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