af83/chouette-core

View on GitHub
app/models/custom_field.rb

Summary

Maintainability
C
1 day
Test Coverage

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

class CustomField < ApplicationModel

  extend Enumerize
  belongs_to :workgroup
  belongs_to :custom_field_group, optional: true
Severity: Minor
Found in app/models/custom_field.rb - About 5 hrs to fix

    Method initialize_custom_field has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def initialize_custom_field
            custom_field_code = self.code
            _attr_name = attr_name
            _uploader_name = uploader_name
            _digest_name = digest_name
    Severity: Major
    Found in app/models/custom_field.rb - About 2 hrs to fix

      Method initialize_custom_field has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize_custom_field
              custom_field_code = self.code
              _attr_name = attr_name
              _uploader_name = uploader_name
              _digest_name = digest_name
      Severity: Minor
      Found in app/models/custom_field.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate
              return unless value.present?
              @valid = true
      
              if collection_is_a_hash?
      Severity: Minor
      Found in app/models/custom_field.rb - About 55 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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def index
              return unless value.present?
              return if collection_is_a_hash?
              return if value.is_a?(::String) && !value.match?(/^[0-9]+$/)
      
      
      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