neo4jrb/neo4j

View on GitHub

Showing 339 of 339 total issues

Method generate_partitioning! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def generate_partitioning!
          @partitioning = [[]]

          @clauses.each do |clause|
            if clause.nil? && !fresh_partition?
Severity: Minor
Found in lib/active_graph/core/query.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 value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def value
          return @value if @value

          [String, Symbol, Integer, Hash, NilClass].each do |arg_class|
            from_method = "from_#{arg_class.name.downcase}"
Severity: Minor
Found in lib/active_graph/core/query_clauses.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 wrapper has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def wrapper(rel)
        rel.properties.symbolize_keys!
        begin
          most_concrete_class = class_from_type(rel.type).constantize
          return rel unless most_concrete_class < ActiveGraph::Relationship
Severity: Minor
Found in lib/active_graph/relationship/rel_wrapper.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 attribute! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      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|
Severity: Minor
Found in lib/active_graph/shared/property.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 association_proxy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def association_proxy(name, options = {})
      name = name.to_sym
      hash = association_proxy_hash(name, options)
      association_proxy_cache_fetch(hash) do
        if result_cache = self.instance_variable_get('@source_proxy_result_cache')
Severity: Minor
Found in lib/active_graph/node/has_n.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 clause_strings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def clause_strings(clauses)
            clauses.flat_map do |clause|
              Array(clause.value).map do |v|
                (clause.options[:not] ? 'NOT' : '') + (v.to_s.match(PAREN_SURROUND_REGEX) ? v.to_s : "(#{v})")
              end
Severity: Minor
Found in lib/active_graph/core/query_clauses.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 constraint_or_index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def constraint_or_index(name, options)
        # either constraint or index, do not set both
        if options[:constraint]
          fail "unknown constraint type #{options[:constraint]}, only :unique supported" if options[:constraint] != :unique
          constraint(name, type: :unique)
Severity: Minor
Found in lib/active_graph/shared/property.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 hash_key_value_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def hash_key_value_string(key, value, previous_keys)
          value.map do |k, v|
            if k.to_sym == :neo_id
              v = Array(v).map { |item| (item.respond_to?(:neo_id) ? item.neo_id : item).to_i }
              key_value_string("ID(#{key})", v)
Severity: Minor
Found in lib/active_graph/core/query_clauses.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 key_value_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def key_value_string(key, value, previous_keys = [], is_set = false)
          param = (previous_keys << key).join(UNDERSCORE)
          self.class.paramaterize_key!(param)

          if value.is_a?(Range)
Severity: Minor
Found in lib/active_graph/core/query_clauses.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 convert_properties_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_properties_to(obj, medium, properties)
      direction = medium == :ruby ? :to_ruby : :to_db
      properties.to_h.each_pair do |key, value|
        next if skip_conversion?(obj, key, value)

Severity: Minor
Found in lib/active_graph/shared/type_converters.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 target_class_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def target_class_option(model_class)
          case model_class
          when nil
            @target_class_name_from_name ? "#{association_model_namespace}::#{@target_class_name_from_name}" : @target_class_name_from_name
          when Array
Severity: Minor
Found in lib/active_graph/node/has_n/association.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        define_class_method(name) do |node = nil, rel = nil, options = {}|
          options, node = node, nil if node.is_a?(Hash)

          options = default_options.merge(options)

Severity: Minor
Found in lib/active_graph/node/has_n.rb and 1 other location - About 45 mins to fix
lib/active_graph/node/has_n.rb on lines 434..439

Duplicated Code

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).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        define_class_method(name) do |node = nil, rel = nil, options = {}|
          options, node = node, nil if node.is_a?(Hash)

          options = default_options.merge(options)

Severity: Minor
Found in lib/active_graph/node/has_n.rb and 1 other location - About 45 mins to fix
lib/active_graph/node/has_n.rb on lines 485..490

Duplicated Code

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).

Tuning

This issue has a mass of 39.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method unique_nodes has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def unique_nodes(association, self_identifer, other_node, other_rel, ids = [])
Severity: Minor
Found in lib/active_graph/node/dependent/query_proxy_methods.rb - About 35 mins to fix

Method unique_nodes_query has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def unique_nodes_query(association, self_identifer, other_node, other_rel, ids)
Severity: Minor
Found in lib/active_graph/node/dependent/query_proxy_methods.rb - About 35 mins to fix

Method arrow_cypher has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def arrow_cypher(var = nil, properties = {}, create = false, reverse = false, length = nil)
Severity: Minor
Found in lib/active_graph/node/has_n/association_cypher_methods.rb - About 35 mins to fix

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

        def derive_model_class
          refresh_model_class! if pending_model_refresh?
          return @model_class unless @model_class.nil?
          return nil if relationship_class.nil?
          dir_class = direction == :in ? :from_class : :to_class
Severity: Minor
Found in lib/active_graph/node/has_n/association.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 inherit_id_property has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.inherit_id_property(other)
        return if other.manual_id_property? || !self.id_property?
        id_prop = self.id_property_info
        conf = id_prop[:type].empty? && id_prop[:name] != :neo_id ? {auto: :uuid} : id_prop[:type]
        other.id_property id_prop[:name], conf, true
Severity: Minor
Found in lib/active_graph/node.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 to_other has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def to_other(direction, value, type)
        fail "Unknown direction given: #{direction}" unless direction == :to_ruby || direction == :to_db
        found_converter = converter_for(type)
        return value unless found_converter
        return value if direction == :to_db && formatted_for_db?(found_converter, value)
Severity: Minor
Found in lib/active_graph/shared/type_converters.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 include? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def include?(other, target = nil)
          query_with_target(target) do |var|
            where_filter = if other.respond_to?(:neo_id) || association_id_key == :neo_id
                             "ID(#{var}) = $other_node_id"
                           else
Severity: Minor
Found in lib/active_graph/node/query/query_proxy_methods.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

Severity
Category
Status
Source
Language