neoid-gem/neoid

View on GitHub

Showing 10 of 10 total issues

Method initialize_relationship has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize_relationship(rel_model)
        rel_model.reflect_on_all_associations(:belongs_to).each do |belongs_to|
          return if belongs_to.options[:polymorphic]

          # e.g. all has_many on User class
Severity: Minor
Found in lib/neoid/relationship.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 _neo_save has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def _neo_save
        return unless Neoid.enabled?

        data = to_neo.merge(ar_type: self.class.name, ar_id: id, Neoid::UNIQUE_ID_KEY => neo_unique_id)
        data.reject! { |k, v| v.nil? }
Severity: Minor
Found in lib/neoid/node.rb - About 1 hr to fix

    Method _neo_save has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def _neo_save
            return unless Neoid.enabled?
    
            options = self.class.neoid_config.relationship_options
    
    
    Severity: Minor
    Found in lib/neoid/relationship.rb - About 1 hr to fix

      Method search has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def search(types, term, options = {})
            options = options.reverse_merge(limit: 15, match_type: 'AND')
      
            types = [*types]
      
      
      Severity: Minor
      Found in lib/neoid.rb - About 1 hr to fix

        Method to_neo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def to_neo
                if self.class.neoid_config.stored_fields
                  hash = self.class.neoid_config.stored_fields.inject({}) do |all, (field, block)|
                    all[field] = if block
                      instance_eval(&block)
        Severity: Minor
        Found in lib/neoid/model_additions.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 search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def search(types, term, options = {})
              options = options.reverse_merge(limit: 15, match_type: 'AND')
        
              types = [*types]
        
        
        Severity: Minor
        Found in lib/neoid.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 _neo_save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def _neo_save
                return unless Neoid.enabled?
        
                options = self.class.neoid_config.relationship_options
        
        
        Severity: Minor
        Found in lib/neoid/relationship.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 generate_field_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_field_query(field, term, fulltext = false, match_type = 'AND')
              term = term.to_s if term
              return '' if term.nil? || term.empty?
        
              fulltext = fulltext ? '_fulltext' : nil
        Severity: Minor
        Found in lib/neoid.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 _neo_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def _neo_save
                return unless Neoid.enabled?
        
                data = to_neo.merge(ar_type: self.class.name, ar_id: id, Neoid::UNIQUE_ID_KEY => neo_unique_id)
                data.reject! { |k, v| v.nil? }
        Severity: Minor
        Found in lib/neoid/node.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

        Method process_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_results(results)
              results.map! do |result|
                return result unless result.is_a?(Hash) && result['self'] && result['self'][%r[^https?://.*/(node|relationship)/\d+]]
        
                type = case $1
        Severity: Minor
        Found in lib/neoid/batch.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

        Severity
        Category
        Status
        Source
        Language