neo4jrb/neo4j

Very high overall complexity: 311

module Neo4j
  module ActiveNode
    module Query
      # rubocop:disable Metrics/ModuleLength
      module QueryProxyMethods
Found in Neo4j::ActiveNode::Query::QueryProxyMethods - About 2 days to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very high overall complexity: 296

module Neo4j
  module ActiveNode
    module Query
      # rubocop:disable Metrics/ClassLength
      class QueryProxy
Found in Neo4j::ActiveNode::Query::QueryProxy - About 2 days to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very high overall complexity: 284

module Neo4j::ActiveNode
  module HasN
    extend ActiveSupport::Concern

    class NonPersistedNodeError < Neo4j::Error; end
Found in Neo4j::ActiveNode::HasN::ClassMethods - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very high overall complexity: 277

require 'active_support/inflector/inflections'
require 'neo4j/class_arguments'

module Neo4j
  module ActiveNode
Found in Neo4j::ActiveNode::HasN::Association - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Identical code found in 1 other location

module Neo4j::ActiveNode
  module HasN
    extend ActiveSupport::Concern

    class NonPersistedNodeError < Neo4j::Error; end
Found in Neo4j::ActiveNode::HasN::ClassMethods and 1 other location - About 1 day to fix
lib/neo4j/active_node/has_n.rb on lines 387..390

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Identical code found in 1 other location

module Neo4j::ActiveNode
  module HasN
    extend ActiveSupport::Concern

    class NonPersistedNodeError < Neo4j::Error; end
Found in Neo4j::ActiveNode::HasN::ClassMethods and 1 other location - About 1 day to fix
lib/neo4j/active_node/has_n.rb on lines 430..433

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

High overall complexity: 228

module Neo4j::Shared
  # rubocop:disable Metrics/ModuleLength
  module Persistence
    # rubocop:enable Metrics/ModuleLength
    extend ActiveSupport::Concern
Found in Neo4j::Shared::Persistence - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Identical code found in 1 other location

require 'neo4j/core/label'

module Neo4j
  module ActiveNode
    # Provides a mapping between neo4j labels and Ruby classes
lib/neo4j/active_rel/types.rb on lines 49..55

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Identical code found in 1 other location

module Neo4j
  module ActiveRel
    # provides mapping of type to model name
    module Types
      extend ActiveSupport::Concern
Found in Neo4j::ActiveRel::Types::ClassMethods and 1 other location - About 7 hrs to fix
lib/neo4j/active_node/labels.rb on lines 202..208

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Complex class definition

require 'active_support/notifications'
require 'rails/railtie'
require 'neo4j/session_manager'
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
require 'action_dispatch/railtie'
Found in Neo4j::Railtie - About 6 hrs to fix

    Complex class definition

    require 'neo4j/class_arguments'
    
    module Neo4j::ActiveRel
      module Property
        extend ActiveSupport::Concern
    Found in Neo4j::ActiveRel::Property - About 6 hrs to fix

      Complex class definition

      module Neo4j
        # Makes Neo4j nodes and relationships behave like ActiveRecord objects.
        # By including this module in your class it will create a mapping for the node to your ruby class
        # by using a Neo4j Label with the same name as the class. When the node is loaded from the database it
        # will check if there is a ruby class for the labels it has.
      Found in Neo4j::ActiveNode - About 5 hrs to fix

        Identical code found in 1 other location

        module Neo4j
          # Makes Neo4j Relationships more or less act like ActiveRecord objects.
          # See documentation at https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel
          module ActiveRel
            extend ActiveSupport::Concern
        Found in Neo4j::ActiveRel and 1 other location - About 5 hrs to fix
        lib/neo4j/shared.rb on lines 44..49

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Identical code found in 1 other location

        module Neo4j
          module Shared
            # This module provides a convenient way of registering a custom Typecasting class. Custom Typecasters all follow a simple pattern.
            #
            # EXAMPLE:
        Found in Neo4j::Shared and 1 other location - About 5 hrs to fix
        lib/neo4j/active_rel.rb on lines 47..52

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Complex class definition

        module Neo4j
          module ActiveNode
            module Query
              # rubocop:disable Metrics/ClassLength
              class QueryProxy
        Found in Neo4j::ActiveNode::Query::QueryProxy - About 4 hrs to fix

          Similar code found in 1 other location

          require 'set'
          module Neo4j
            # This is here to support the removed functionality of being able to
            # defined indexes and constraints on models
            # This code should be removed later
          Found in Neo4j::ModelSchema and 1 other location - About 3 hrs to fix
          lib/neo4j/model_schema.rb on lines 35..37

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Refactorings

          Further Reading

          Similar code found in 1 other location

          require 'set'
          module Neo4j
            # This is here to support the removed functionality of being able to
            # defined indexes and constraints on models
            # This code should be removed later
          Found in Neo4j::ModelSchema and 1 other location - About 3 hrs to fix
          lib/neo4j/model_schema.rb on lines 46..48

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Refactorings

          Further Reading

          Complex method in #validate_model_schema!

                def validate_model_schema!
                  ensure_model_data_state!
                  messages = {index: [], constraint: []}
                  each_schema_element do |type, model, label, property_name, exists|
                    if exists
          Found in Neo4j::ModelSchema - About 3 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex class definition

          module Neo4j
            # Makes Neo4j Relationships more or less act like ActiveRecord objects.
            # See documentation at https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel
            module ActiveRel
              extend ActiveSupport::Concern
          Found in Neo4j::ActiveRel - About 3 hrs to fix

            Complex method in #model_indexes

                  def model_indexes
                    return @model_indexes if @model_indexes
            
                    indexes = Neo4j::ActiveBase.current_session.indexes.each_with_object({}) do |row, result|
                      result[row[:label]] ||= []
            Found in Neo4j::ModelSchema - About 3 hrs to fix

            Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

            Refactorings

            Read More

            Similar code found in 1 other location

            module Neo4j
              module Shared
                module Callbacks #:nodoc:
                  extend ActiveSupport::Concern
            
            
            Found in Neo4j::Shared::Callbacks and 1 other location - About 3 hrs to fix
            lib/neo4j/shared/callbacks.rb on lines 53..56

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Refactorings

            Further Reading

            Similar code found in 1 other location

            module Neo4j
              module Shared
                module Callbacks #:nodoc:
                  extend ActiveSupport::Concern
            
            
            Found in Neo4j::Shared::Callbacks and 1 other location - About 3 hrs to fix
            lib/neo4j/shared/callbacks.rb on lines 60..63

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Refactorings

            Further Reading

            Complex class definition

            require 'neo4j/class_arguments'
            
            module Neo4j::ActiveRel
              module Property
                extend ActiveSupport::Concern
            Found in Neo4j::ActiveRel::Property::ClassMethods - About 2 hrs to fix

              Complex method in #define_has_many_id_methods

                    def define_has_many_id_methods(name)
                      define_method_unless_defined("#{name.to_s.singularize}_ids") do
                        association_proxy(name).result_ids
                      end
              
              
              Found in Neo4j::ActiveNode::HasN::ClassMethods - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #unique_nodes_query

                      def unique_nodes_query(association, self_identifer, other_node, other_rel)
                        query.with(identity).proxy_as_optional(source_object.class, self_identifer)
                             .send(association.name, other_node, other_rel)
                             .query
                             .with(other_node)

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #association_method_keys

                    def association_method_keys
                      @association_method_keys ||=
                        associations_keys.map(&:to_sym) +
                        associations.values.map do |association|
                          if association.type == :has_one
              Found in Neo4j::ActiveNode::Property::ClassMethods - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #build!

                  def build!
                    node_before_callbacks! do
                      res = query_factory(rel, rel_id, iterative_query).query.unwrapped.return(*unpersisted_return_ids).first
                      node_symbols.each { |n| wrap!(send(n), res, n) }
                      @unwrapped_rel = res.send(rel_id)
              Found in Neo4j::ActiveRel::Persistence::QueryFactory - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #scope

                    def scope(name, proc)
                      scopes[name.to_sym] = proc
              
                      klass = class << self; self; end
                      klass.instance_eval do
              Found in Neo4j::ActiveNode::Scope::ClassMethods - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #define_has_one_getter

                    def define_has_one_getter(name)
                      define_method(name) do |node = nil, rel = nil, options = {}|
                        options, node = node, nil if node.is_a?(Hash)
              
                        # Return all results if a variable-length relationship length was given
              Found in Neo4j::ActiveNode::HasN::ClassMethods - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #constantize_argument

                    def constantize_argument(class_argument)
                      case class_argument
                      when 'any', :any, false, nil
                        nil
                      when Array
              Found in Neo4j::ClassArguments - About 2 hrs to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Similar code found in 1 other location

              module Neo4j
                module ActiveNode
                  module Query
                    # rubocop:disable Metrics/ModuleLength
                    module QueryProxyMethods
              lib/neo4j/active_node/query/query_proxy_methods.rb on lines 197..199

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Refactorings

              Further Reading

              Similar code found in 1 other location

              module Neo4j
                module ActiveNode
                  module Query
                    # rubocop:disable Metrics/ModuleLength
                    module QueryProxyMethods
              lib/neo4j/active_node/query/query_proxy_methods.rb on lines 211..213

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Refactorings

              Further Reading

              Similar code found in 1 other location

              module Neo4j::Shared
                class DeclaredProperty
                  # None of these methods interact with the database. They only keep track of property settings in models.
                  # It could (should?) handle the actual indexing/constraining, but that's TBD.
                  module Index
              Found in Neo4j::Shared::DeclaredProperty::Index and 1 other location - About 2 hrs to fix
              lib/neo4j/shared/declared_property/index.rb on lines 23..25

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Refactorings

              Further Reading

              Similar code found in 1 other location

              module Neo4j::Shared
                class DeclaredProperty
                  # None of these methods interact with the database. They only keep track of property settings in models.
                  # It could (should?) handle the actual indexing/constraining, but that's TBD.
                  module Index
              Found in Neo4j::Shared::DeclaredProperty::Index and 1 other location - About 2 hrs to fix
              lib/neo4j/shared/declared_property/index.rb on lines 18..20

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Refactorings

              Further Reading

              Complex method in #to_ruby

                      def to_ruby(value)
                        return value if value.is_a?(DateTime)
                        t = case value
                            when Time
                              return value.to_datetime.utc

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex class definition

              module Neo4j
                module Migrations
                  class Runner
                    STATUS_TABLE_FORMAT = '%-10s %-20s %s'.freeze
                    SEPARATOR = '--------------------------------------------------'.freeze
              Found in Neo4j::Migrations::Runner - About 1 hr to fix

                Complex method in #wrapper

                      def wrapper(rel)
                        rel.props.symbolize_keys!
                        begin
                          most_concrete_class = class_from_type(rel.rel_type)
                          most_concrete_class.constantize.new
                Found in Neo4j::RelWrapping - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #previous_proxy_results_by_previous_id

                    def previous_proxy_results_by_previous_id(result_cache, association_name)
                      query_proxy = self.class.as(:previous).where(neo_id: result_cache.map(&:neo_id))
                      query_proxy = self.class.send(:association_query_proxy, association_name, previous_query_proxy: query_proxy, node: :next, optional: true)
                
                      Hash[*query_proxy.pluck('ID(previous)', 'collect(next)').flatten(1)].each do |_, records|
                Found in Neo4j::ActiveNode::HasN - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #attribute!

                      def attribute!(name)
                        remove_instance_variable('@attribute_methods_generated') if instance_variable_defined?('@attribute_methods_generated')
                        define_attribute_methods([name]) unless attribute_names.include?(name)
                        attributes[name.to_s] = declared_properties[name]
                        define_method("#{name}=") do |value|
                Found in Neo4j::Shared::Property::ClassMethods - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More