neo4jrb/neo4j

View on GitHub

Showing 342 of 342 total issues

File query_clauses.rb has 584 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveGraph
  module Core
    module QueryClauses
      class ArgError < StandardError
        attr_reader :arg_part
Severity: Major
Found in lib/active_graph/core/query_clauses.rb - About 1 day to fix

Class QueryProxy has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

      class QueryProxy
        # rubocop:enable Metrics/ClassLength
        include ActiveGraph::Node::Query::QueryProxyEnumerable
        include ActiveGraph::Node::Query::QueryProxyMethods
        include ActiveGraph::Node::Query::QueryProxyMethodsOfMassUpdating
Severity: Minor
Found in lib/active_graph/node/query/query_proxy.rb - About 5 hrs to fix

File has_n.rb has 367 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveGraph::Node
  module HasN
    extend ActiveSupport::Concern

    class NonPersistedNodeError < ActiveGraph::Error; end
Severity: Minor
Found in lib/active_graph/node/has_n.rb - About 4 hrs to fix

Class Association has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Association
        include ActiveGraph::Shared::RelTypeConverters
        include ActiveGraph::Node::Dependent::AssociationMethods
        include ActiveGraph::Node::HasN::AssociationCypherMethods

Severity: Minor
Found in lib/active_graph/node/has_n/association.rb - About 4 hrs to fix

File type_converters.rb has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
require 'bigdecimal'
require 'bigdecimal/util'
require 'active_support/core_ext/big_decimal/conversions'
require 'active_support/core_ext/string/conversions'
Severity: Minor
Found in lib/active_graph/shared/type_converters.rb - About 4 hrs to fix

Class Query has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Query
      include ActiveGraph::Core::QueryClauses
      include ActiveGraph::Core::QueryFindInBatches
      DEFINED_CLAUSES = {}

Severity: Minor
Found in lib/active_graph/core/query.rb - About 4 hrs to fix

Class DeclaredProperties has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class DeclaredProperties
    include ActiveGraph::Shared::TypeConverters

    attr_reader :klass
    delegate :each, :each_pair, :each_key, :each_value, to: :registered_properties
Severity: Minor
Found in lib/active_graph/shared/declared_properties.rb - About 3 hrs to fix

Class Runner has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Runner
      STATUS_TABLE_FORMAT = '%-10s %-20s %s'.freeze
      SEPARATOR = '--------------------------------------------------'.freeze
      FILE_MISSING = '**** file missing ****'.freeze
      STATUS_TABLE_HEADER = ['Status'.freeze, 'Migration ID'.freeze, 'Migration Name'.freeze].freeze
Severity: Minor
Found in lib/active_graph/migrations/runner.rb - About 3 hrs to fix

Class Clause has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Clause
        UNDERSCORE = '_'
        COMMA_SPACE = ', '
        AND = ' AND '
        PRETTY_NEW_LINE = "\n  "
Severity: Minor
Found in lib/active_graph/core/query_clauses.rb - About 3 hrs to fix

Class AssociationProxy has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AssociationProxy
      def initialize(query_proxy, deferred_objects = [], result_cache_proc = nil)
        @query_proxy = query_proxy
        @deferred_objects = deferred_objects

Severity: Minor
Found in lib/active_graph/node/has_n.rb - About 3 hrs to fix

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

        def subscribe_to_query
          ActiveSupport::Notifications.subscribe('neo4j.core.cypher_query') do |_, _start, _finish, _id, payload|
            query = payload[:query]
            params_string = (query.parameters && !query.parameters.empty? ? "| #{query.parameters.inspect}" : EMPTY)
            cypher = query.pretty_cypher ? (NEWLINE_W_SPACES if query.pretty_cypher.include?("\n")).to_s + query.pretty_cypher.gsub(/\n/, NEWLINE_W_SPACES) : query.cypher
Severity: Minor
Found in lib/active_graph/core/instrumentable.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 query.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'active_graph/core/query_clauses'
require 'active_graph/core/query_find_in_batches'
require 'active_support/notifications'

module ActiveGraph
Severity: Minor
Found in lib/active_graph/core/query.rb - About 2 hrs to fix

Assignment Branch Condition size for subscribe_to_query is too high. [23.85/18] (http://c2.com/cgi/wiki?AbcMetric)
Open

        def subscribe_to_query
          ActiveSupport::Notifications.subscribe('neo4j.core.cypher_query') do |_, _start, _finish, _id, payload|
            query = payload[:query]
            params_string = (query.parameters && !query.parameters.empty? ? "| #{query.parameters.inspect}" : EMPTY)
            cypher = query.pretty_cypher ? (NEWLINE_W_SPACES if query.pretty_cypher.include?("\n")).to_s + query.pretty_cypher.gsub(/\n/, NEWLINE_W_SPACES) : query.cypher

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for subscribe_to_query is too high. [8/6]
Open

        def subscribe_to_query
          ActiveSupport::Notifications.subscribe('neo4j.core.cypher_query') do |_, _start, _finish, _id, payload|
            query = payload[:query]
            params_string = (query.parameters && !query.parameters.empty? ? "| #{query.parameters.inspect}" : EMPTY)
            cypher = query.pretty_cypher ? (NEWLINE_W_SPACES if query.pretty_cypher.include?("\n")).to_s + query.pretty_cypher.gsub(/\n/, NEWLINE_W_SPACES) : query.cypher

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for setup! is too high. [19.54/18] (http://c2.com/cgi/wiki?AbcMetric)
Open

    def setup!(config = empty_config)
      config = final_driver_config!(config)
      scheme = config.delete(:scheme) || 'bolt'
      host = config.delete(:host) || 'localhost'
      port = config.delete(:port) || 7687
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for setup! is too high. [7/6]
Open

    def setup!(config = empty_config)
      config = final_driver_config!(config)
      scheme = config.delete(:scheme) || 'bolt'
      host = config.delete(:host) || 'localhost'
      port = config.delete(:port) || 7687
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for subscribe_to_query is too high. [8/7]
Open

        def subscribe_to_query
          ActiveSupport::Notifications.subscribe('neo4j.core.cypher_query') do |_, _start, _finish, _id, payload|
            query = payload[:query]
            params_string = (query.parameters && !query.parameters.empty? ? "| #{query.parameters.inspect}" : EMPTY)
            cypher = query.pretty_cypher ? (NEWLINE_W_SPACES if query.pretty_cypher.include?("\n")).to_s + query.pretty_cypher.gsub(/\n/, NEWLINE_W_SPACES) : query.cypher

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

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

      def process_unpersisted_nodes!
        deferred_create_cache.dup.each do |association_name, nodes|
          association_proxy = association_proxy(association_name)

          nodes.each do |node|
Severity: Minor
Found in lib/active_graph/node/unpersisted.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 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 process_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def process_attributes(attributes = nil)
      return attributes if attributes.blank?
      multi_parameter_attributes = {}
      new_attributes = {}
      attributes.each_pair do |key, value|
Severity: Minor
Found in lib/active_graph/shared/property.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

Severity
Category
Status
Source
Language