Method journalize_changes
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def journalize_changes
# attributes changes
if @attributes_before_change
attrs = (journalized.journalized_attribute_names + @attributes_before_change.keys).uniq
attrs.each do |attribute|
- 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
Class Journal
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Journal < ApplicationRecord
include Redmine::SafeAttributes
belongs_to :journalized, :polymorphic => true
# added as a quick fix to allow eager loading of the polymorphic association
File journal.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Journal < ApplicationRecord
include Redmine::SafeAttributes
belongs_to :journalized, :polymorphic => true
# added as a quick fix to allow eager loading of the polymorphic association
Consider simplifying this complex logical expression. Open
if notify? &&
(
Setting.notified_events.include?('issue_updated') ||
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
Method send_notification
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send_notification
if notify? &&
(
Setting.notified_events.include?('issue_updated') ||
(Setting.notified_events.include?('issue_note_added') && notes.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 journalize_changes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def journalize_changes
# attributes changes
if @attributes_before_change
attrs = (journalized.journalized_attribute_names + @attributes_before_change.keys).uniq
attrs.each do |attribute|
Method split_private_notes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def split_private_notes
if private_notes?
if notes.present?
if details.any?
# Split the journal (notes/changes) so we don't have half-private journals
- 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 visible_details
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def visible_details(user=User.current)
details.select do |detail|
if detail.property == 'cf'
detail.custom_field && detail.custom_field.visible_by?(project, user)
elsif detail.property == 'relation'
- 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"