redmine/redmine

View on GitHub
app/models/journal.rb

Summary

Maintainability
D
2 days
Test Coverage

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|
Severity: Minor
Found in app/models/journal.rb - About 4 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

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
Severity: Minor
Found in app/models/journal.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in app/models/journal.rb - About 2 hrs to fix

      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?) ||
      Severity: Critical
      Found in app/models/journal.rb - About 2 hrs to fix

        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?) ||
        Severity: Minor
        Found in app/models/journal.rb - About 1 hr 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 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|
        Severity: Minor
        Found in app/models/journal.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in app/models/journal.rb - About 35 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 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'
          Severity: Minor
          Found in app/models/journal.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