openjaf/cenit

View on GitHub
app/models/setup/cross_shared_collection.rb

Summary

Maintainability
D
2 days
Test Coverage

File cross_shared_collection.rb has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Setup
  class CrossSharedCollection
    include CenitUnscoped
    include CrossOrigin::CenitDocument
    include CollectionBehavior
Severity: Minor
Found in app/models/setup/cross_shared_collection.rb - About 4 hrs to fix

    Method install has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def install(options)
          collection = options[:collection]
          origin = options[:origin] || (self.origin == :default ? self.class.default_origin : self.origin)
          collection.add_dependencies if options[:add_dependencies]
    
    
    Severity: Minor
    Found in app/models/setup/cross_shared_collection.rb - About 3 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 CrossSharedCollection has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class CrossSharedCollection
        include CenitUnscoped
        include CrossOrigin::CenitDocument
        include CollectionBehavior
        include Taggable
    Severity: Minor
    Found in app/models/setup/cross_shared_collection.rb - About 3 hrs to fix

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

          def install(options)
            collection = options[:collection]
            origin = options[:origin] || (self.origin == :default ? self.class.default_origin : self.origin)
            collection.add_dependencies if options[:add_dependencies]
      
      
      Severity: Major
      Found in app/models/setup/cross_shared_collection.rb - About 2 hrs to fix

        Method config_pull_parameters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def config_pull_parameters
              unless @config_pull_parameters
                @config_pull_parameters = []
                [Setup::RemoteOauthClient, Setup::GenericAuthorizationClient].each do |client_model|
                  clients = COLLECTING_PROPERTIES.detect { |p| reflect_on_association(p).klass == client_model }.to_s
        Severity: Minor
        Found in app/models/setup/cross_shared_collection.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 method_missing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def method_missing(symbol, *args)
              if (match = /\Adata_(.+)\Z/.match(symbol.to_s)) &&
                 COLLECTING_PROPERTIES.include?(relation_name = match[1].to_sym) &&
                 ((args.length.zero? && (options = {})) || args.length == 1 && (options = args[0]).is_a?(Hash))
                if (items = send(relation_name)).present?
        Severity: Minor
        Found in app/models/setup/cross_shared_collection.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 validates_pull_parameters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def validates_pull_parameters
              with_errors = false
              data =
                if installed
                  if new_record?
        Severity: Minor
        Found in app/models/setup/cross_shared_collection.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 config_pull_parameters has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def config_pull_parameters
              unless @config_pull_parameters
                @config_pull_parameters = []
                [Setup::RemoteOauthClient, Setup::GenericAuthorizationClient].each do |client_model|
                  clients = COLLECTING_PROPERTIES.detect { |p| reflect_on_association(p).klass == client_model }.to_s
        Severity: Minor
        Found in app/models/setup/cross_shared_collection.rb - About 1 hr to fix

          Method validates_pull_parameters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def validates_pull_parameters
                with_errors = false
                data =
                  if installed
                    if new_record?
          Severity: Minor
          Found in app/models/setup/cross_shared_collection.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                  if (match = /\Adata_(.+)\Z/.match(symbol.to_s)) &&
                     COLLECTING_PROPERTIES.include?(relation_name = match[1].to_sym) &&
                     ((args.length.zero? && (options = {})) || args.length == 1 && (options = args[0]).is_a?(Hash))
                    if (items = send(relation_name)).present?
                      items
            Severity: Major
            Found in app/models/setup/cross_shared_collection.rb - About 40 mins to fix

              Method generate_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def generate_data
                    hash = {}
                    if installed?
                      visited = Set.new
                      COLLECTING_PROPERTIES.each do |property|
              Severity: Minor
              Found in app/models/setup/cross_shared_collection.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 hash_attribute_read has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def hash_attribute_read(name, value)
                    case name
                      when 'data'
                        installed? ? generate_data : value
                      when 'pull_data'
              Severity: Minor
              Found in app/models/setup/cross_shared_collection.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 with_reset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def with_reset(hash, model)
                    unless (_reset = hash['_reset'])
                      _reset = hash['_reset'] = []
                    end
                    hash.keys.each do |property|
              Severity: Minor
              Found in app/models/setup/cross_shared_collection.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