redmine/redmine

View on GitHub
app/models/custom_field.rb

Summary

Maintainability
C
1 day
Test Coverage

Class CustomField has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class CustomField < ApplicationRecord
  include Redmine::SafeAttributes
  include Redmine::SubclassFactory

  has_many :enumerations,
Severity: Minor
Found in app/models/custom_field.rb - About 4 hrs to fix

    File custom_field.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class CustomField < ApplicationRecord
      include Redmine::SafeAttributes
      include Redmine::SubclassFactory
    
      has_many :enumerations,
    Severity: Minor
    Found in app/models/custom_field.rb - About 2 hrs to fix

      Method validate_custom_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_custom_value(custom_value)
          value = custom_value.value
          errs = format.validate_custom_value(custom_value)
      
          unless errs.any?
      Severity: Minor
      Found in app/models/custom_field.rb - About 45 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 copy_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def copy_from(arg, options={})
          return if arg.blank?
      
          custom_field = arg.is_a?(CustomField) ? arg : CustomField.find_by(id: arg.to_s)
          self.attributes = custom_field.attributes.dup.except('id', 'name', 'position')
      Severity: Minor
      Found in app/models/custom_field.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 visibility_by_project_condition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def visibility_by_project_condition(project_key=nil, user=User.current, id_column=nil)
          if visible? || user.admin?
            "1=1"
          elsif user.anonymous?
            "1=0"
      Severity: Minor
      Found in app/models/custom_field.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