wrstudios/odata4

View on GitHub

Showing 22 of 22 total issues

Class Entity has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Entity
    # The Entity type name
    attr_reader :type
    # The OData4::Service's identifying name
    attr_reader :service_name
Severity: Minor
Found in lib/odata4/entity.rb - About 4 hrs to fix

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

      class Query
        attr_reader :options
    
        include InBatches
    
    
    Severity: Minor
    Found in lib/odata4/query.rb - About 2 hrs to fix

      Class Service has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Service
          # The Faraday connection object used by the service to make requests
          attr_reader :connection
          # The OData4 Service's URL
          attr_reader :service_url
      Severity: Minor
      Found in lib/odata4/service.rb - About 2 hrs to fix

        Method process_links has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.process_links(entity, xml_doc)
              entity.instance_eval do
                new_links = instance_variable_get(:@links) || {}
                schema.navigation_properties[name].each do |nav_name, details|
                  xml_doc.xpath("./link[@title='#{nav_name}']").each do |node|
        Severity: Minor
        Found in lib/odata4/entity.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 read_metadata has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def read_metadata
              # From file, good for debugging
              if options[:metadata_file]
                data = File.read(options[:metadata_file])
                ::Nokogiri::XML(data).remove_namespaces!
        Severity: Minor
        Found in lib/odata4/service.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 fetch_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def fetch_result
                raise "Invalid navigation link for #{nav_name}" unless link[:href]
        
                options = {
                  type:         nav_property.entity_type,
        Severity: Minor
        Found in lib/odata4/navigation_property/proxy.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate(value)
                return if value.nil? && allows_nil?
                raise ArgumentError, 'Value must be a Hash' unless value.is_a?(Hash)
                value.keys.each do |name|
                  unless property_names.include?(name) || name =~ /@odata/
        Severity: Minor
        Found in lib/odata4/properties/complex.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 process_metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.process_metadata(entity, metadata)
              entity.instance_eval do
                new_links = instance_variable_get(:@links) || {}
                schema.navigation_properties[name].each do |nav_name, details|
                  href = metadata["#{nav_name}@odata.navigationLink"]
        Severity: Minor
        Found in lib/odata4/entity.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate(value)
                return [] if value.nil? && allows_nil?
                values = parse_value(value)
        
                if values.length > 1 && !is_flags?
        Severity: Minor
        Found in lib/odata4/properties/enum.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_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_xml
              namespaces = XML_NAMESPACES.merge('xml:base' => service.service_url)
              builder = Nokogiri::XML::Builder.new do |xml|
                xml.entry(namespaces) do
                  xml.category(term: type,
        Severity: Minor
        Found in lib/odata4/entity.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 process_property_from_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_property_from_xml(property_xml)
              property_name = property_xml.attributes['Name'].value
              property_type = property_xml.attributes['Type'].value
              property_options = { service: service }
        
        
        Severity: Minor
        Found in lib/odata4/schema.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 value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def value
                if (@value.nil? || @value.empty?) && allows_nil?
                  nil
                else
                  begin
        Severity: Minor
        Found in lib/odata4/properties/date_time.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 value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def value
                if link.nil?
                  if nav_property.nav_type == :collection
                    []
                  else
        Severity: Minor
        Found in lib/odata4/navigation_property/proxy.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 << has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def <<(entity)
              url_chunk, options = setup_entity_post_request(entity)
              result = execute_entity_post_request(options, url_chunk)
              if entity.is_new?
                doc = ::Nokogiri::XML(result.body).remove_namespaces!
        Severity: Minor
        Found in lib/odata4/entity_set.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 parse_wkt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def parse_wkt(value)
                  if value =~ /^geography'(SRID=(\d+);)+(\w+)\((.+)\)'$/
                    $3 == type_name or raise ArgumentError, "Invalid geography type '#{$3}'"
                    self.srid = $1 ? $2.to_i : DEFAULT_SRID
                    coords_from_s($4)
        Severity: Minor
        Found in lib/odata4/properties/geography/base.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 check_content_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_content_type
                # Dynamically extend instance with methods for
                # processing the current result type
                if is_atom?
                  extend OData4::Service::Response::Atom
        Severity: Minor
        Found in lib/odata4/service/response.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

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

            SERVER_ERRORS.each do |code, message|
              klass = Class.new(ServerError) do
                send(:define_method, :default_message) { "#{code} #{message}" }
              end
              const_set(message.delete(' \-\''), klass)
        Severity: Minor
        Found in lib/odata4/errors.rb and 1 other location - About 25 mins to fix
        lib/odata4/errors.rb on lines 47..52

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

        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

            CLIENT_ERRORS.each do |code, message|
              klass = Class.new(ClientError) do
                send(:define_method, :default_message) { "#{code} #{message}" }
              end
              const_set(message.delete(' \-\''), klass)
        Severity: Minor
        Found in lib/odata4/errors.rb and 1 other location - About 25 mins to fix
        lib/odata4/errors.rb on lines 60..65

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

        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

            def enum_types
              @enum_types ||= schemas.map do |namespace, schema|
                schema.enum_types.map do |name, enum_type|
                  [ "#{namespace}.#{name}", enum_type ]
                end.to_h
        Severity: Minor
        Found in lib/odata4/service.rb and 1 other location - About 15 mins to fix
        lib/odata4/service.rb on lines 125..131

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

        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

            def complex_types
              @complex_types ||= schemas.map do |namespace, schema|
                schema.complex_types.map do |name, complex_type|
                  [ "#{namespace}.#{name}", complex_type ]
                end.to_h
        Severity: Minor
        Found in lib/odata4/service.rb and 1 other location - About 15 mins to fix
        lib/odata4/service.rb on lines 135..141

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

        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

        Severity
        Category
        Status
        Source
        Language