openjaf/cenit

View on GitHub
app/models/concerns/setup/collection_behavior.rb

Summary

Maintainability
D
2 days
Test Coverage

Method add_dependencies has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

    def add_dependencies
      return true unless @add_dependencies
      self.warnings = []
      collecting_models = {}
      COLLECTING_PROPERTIES.each do |property|
Severity: Minor
Found in app/models/concerns/setup/collection_behavior.rb - About 1 day 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 add_dependencies has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def add_dependencies
      return true unless @add_dependencies
      self.warnings = []
      collecting_models = {}
      COLLECTING_PROPERTIES.each do |property|
Severity: Major
Found in app/models/concerns/setup/collection_behavior.rb - About 3 hrs to fix

    Method scan_dependencies_on has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def scan_dependencies_on(record, opts)
          return false if opts[:visited].include?(record) || record.is_a?(Setup::CenitDataType)
          opts[:visited] << record
          record.class.reflect_on_all_associations(:embeds_one,
                                                   :embeds_many,
    Severity: Minor
    Found in app/models/concerns/setup/collection_behavior.rb - About 2 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

    Method cross_to has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def cross_to(origin = :default, criteria = {})
          COLLECTING_PROPERTIES.each do |property|
            r = reflect_on_association(property)
            next unless (model = r.klass).include?(Setup::CrossOriginShared)
            criteria = criteria.merge(:origin.ne => :default) if model == Setup::RemoteOauthClient || model == Setup::GenericAuthorizationClient
    Severity: Minor
    Found in app/models/concerns/setup/collection_behavior.rb - About 2 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

    File collection_behavior.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'cenit/cross_tracing_criteria'
    
    module Setup
      module CollectionBehavior
        extend ActiveSupport::Concern
    Severity: Minor
    Found in app/models/concerns/setup/collection_behavior.rb - About 2 hrs to fix

      There are no issues that match your filters.

      Category
      Status