ruprict/oriented

View on GitHub

Showing 27 of 27 total issues

Class VertexInstance has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class VertexInstance
      include Enumerable
      extend Oriented::Core::TransactionWrapper

      def initialize(vertex, rel_type)
Severity: Minor
Found in lib/oriented/relationships/vertex_instance.rb - About 2 hrs to fix

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

    module Oriented
    
      # This module was copied from neo4j-wrapper
      module TypeConverters
    
    
    Severity: Minor
    Found in lib/oriented/type_converters.rb - About 2 hrs to fix

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

        module Core
          class JavaVertex
              extend Oriented::Core::Vertex::ClassMethods    
              extend Oriented::Core::Wrapper::ClassMethods
      
      
      Severity: Major
      Found in lib/oriented/core/java_vertex.rb and 1 other location - About 1 hr to fix
      lib/oriented/core/java_edge.rb on lines 2..43

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

      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

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

        module Core
          class JavaEdge
                extend Oriented::Core::Edge::ClassMethods    
                extend Oriented::Core::Wrapper::ClassMethods
                # 
      Severity: Major
      Found in lib/oriented/core/java_edge.rb and 1 other location - About 1 hr to fix
      lib/oriented/core/java_vertex.rb on lines 2..41

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

      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 destroy_relationship_to has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def destroy_relationship_to(other)
              relationships().each do |e|
                javaobj = (e.respond_to?(:__java_obj) ? e.__java_obj : e)
                if javaobj
                  if e.start_vertex.id == other.id || e.end_vertex.id == other.id
      Severity: Minor
      Found in lib/oriented/relationships/vertex_instance.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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def update(struct_or_hash, options={})
              protected_keys = self.class.protected_keys if options[:strict]
              protected_keys ||= options[:protected_keys].map(&:to_s) if options[:protected_keys]
              keys_to_delete = props.keys - protected_keys if protected_keys
      
      
      Severity: Minor
      Found in lib/oriented/core/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

      Method parse_date_from_string has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse_date_from_string(value)
                return value unless value.class == String
                match = value.match(/[-|\/]\d{2}$/)
                if match
                  if value[/\//]
      Severity: Minor
      Found in lib/oriented/type_converters.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 get! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def get!(rid)          
              if rid.kind_of?(Hash)
                if rid.count > 1
      
                else
      Severity: Minor
      Found in lib/oriented/vertex_persistence.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 property has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def property(*props)
              options = props.last.kind_of?(Hash) ? props.pop : {}
              props.each do |prop|
                raise RestrctedPropertyError if RESTRICTED_PROPERTIES.include?(prop)
                next if _props.has_key?(prop)
      Severity: Minor
      Found in lib/oriented/properties.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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
      
            raise ArgumentError.new "Start vertex not supplied" unless start_vertex
            raise ArgumentError.new "Start vertex is not a vertex" unless start_vertex.is_a?(Vertex)
            raise ArgumentError.new "End vertex not supplied" unless end_vertex
      Severity: Minor
      Found in lib/oriented/edge_persistence.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 has_one has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def has_one(rel_label, options={})
              method_name = rel_label.downcase
              unless method_defined?(method_name)
                class_eval <<-RUBY, __FILE__, __LINE__
                  def #{method_name} 
      Severity: Minor
      Found in lib/oriented/relationships.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(*args)
              return initialize_attributes(nil) if args.size < 3 # then we have been loaded
        
              
              start_vertex, end_vertex, label, props = *args
        Severity: Minor
        Found in lib/oriented/edge_persistence.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 validate_constructor_args has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate_constructor_args(*args)
                start_vertex, end_vertex, label, props = *args
                raise ArgumentError.new "Start vertex not supplied" unless start_vertex
                raise ArgumentError.new "Start vertex is not a vertex" unless start_vertex.is_a?(Vertex)
                raise ArgumentError.new "End vertex not supplied" unless end_vertex
        Severity: Minor
        Found in lib/oriented/edge/edge_methods.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 []= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def []=(key, value)
                raise "Not valid OrientDB Property value #{value.class}, valid: #{VALID_PROPERTY_VALUE_CLASSES.to_a.join(', ')}" unless valid_property?(value)
                
                k = key.to_s
                if value.nil?
        Severity: Minor
        Found in lib/oriented/core/property.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.run connection = Oriented.connection, options={}, &block
                puts options.inspect if options[:commit_on_sucess]
                ensure_connection(connection)
                ret = yield
                connection.commit if options.fetch(:commit_on_success, false) == true
        Severity: Minor
        Found in lib/oriented/core/transaction.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 read_attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_attribute(key)
              @_properties ||= {}      
              key = key.to_s
              if @_properties.has_key?(key)
                @_properties[key]
        Severity: Minor
        Found in lib/oriented/properties.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 new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def new(*args)
        
                  # the first argument can be an hash of properties to set
                  props = args[0].respond_to?(:each_pair) && args[0]
        
        
        Severity: Minor
        Found in lib/oriented/core/vertex/class_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

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

              def create_or_update
                # since the same model can be created or updated twice from a relationship we have to have this guard
                @_create_or_updating = true
                      result = persisted? ? update : create
                      unless result != false
        Severity: Minor
        Found in lib/oriented/persistence.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

        Avoid too many return statements within this method.
        Open

                      return Date.strptime(value, '%m-%d-%Y')
        Severity: Major
        Found in lib/oriented/type_converters.rb - About 30 mins to fix

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

              def write_attribute(key, value)
                @_properties ||= {}      
                key_s = key.to_s
                if !@_properties.has_key?(key_s) || @_properties[key_s] != value
                  attribute_will_change!(key_s)
          Severity: Minor
          Found in lib/oriented/properties.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