ruby-odata/odata

View on GitHub

Showing 15 of 15 total issues

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

  class Service
    # The OData Service's URL
    attr_reader :service_url
    # Options to pass around
    attr_reader :options
Severity: Minor
Found in lib/odata/service.rb - About 3 hrs to fix

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

      class Entity
        # The Entity type name
        attr_reader :type
        # The OData::Service's namespace
        attr_reader :namespace
    Severity: Minor
    Found in lib/odata/entity.rb - About 2 hrs to fix

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

        class Query
          # Create a new Query for the provided EntitySet
          # @param entity_set [OData::EntitySet]
          def initialize(entity_set)
            @entity_set = entity_set
      Severity: Minor
      Found in lib/odata/query.rb - About 2 hrs to fix

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

            def self.process_links(entity, xml_doc)
              entity.instance_eval do
                service.navigation_properties[name].each do |nav_name, details|
                  xml_doc.xpath("./link[@title='#{nav_name}']").each do |node|
                    next if node.attributes['type'].nil?
        Severity: Minor
        Found in lib/odata/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 validate_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_response(response)
              raise "Bad Request. #{error_message(response)}" if response.code == 400
              raise "Access Denied" if response.code == 401
              raise "Forbidden" if response.code == 403
              raise "Invalid URL" if [0,404].include?(response.code)
        Severity: Minor
        Found in lib/odata/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 read_metadata has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

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

              def [](association_name)
                if associations[association_name].nil?
                  raise ArgumentError, "unknown association: #{association_name}"
                elsif entity.links[association_name].nil?
                  association = associations[association_name]
        Severity: Minor
        Found in lib/odata/association/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

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

            def properties_for_complex_type(type_name)
              type_definition = metadata.xpath("//ComplexType[@Name='#{type_name}']").first
              raise ArgumentError, "Unknown ComplexType: #{type_name}" if type_definition.nil?
              properties_to_return = {}
              type_definition.xpath('./Property').each do |property_xml|
        Severity: Minor
        Found in lib/odata/service.rb and 1 other location - About 45 mins to fix
        lib/odata/service.rb on lines 200..208

        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

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

            def properties_for_entity(entity_name)
              type_definition = metadata.xpath("//EntityType[@Name='#{entity_name}']").first
              raise ArgumentError, "Unknown EntityType: #{entity_name}" if type_definition.nil?
              properties_to_return = {}
              type_definition.xpath('./Property').each do |property_xml|
        Severity: Minor
        Found in lib/odata/service.rb and 1 other location - About 45 mins to fix
        lib/odata/service.rb on lines 216..224

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

            def to_xml
              builder = Nokogiri::XML::Builder.new do |xml|
                xml.entry('xmlns'           => 'http://www.w3.org/2005/Atom',
                          'xmlns:data'      => 'http://schemas.microsoft.com/ado/2007/08/dataservices',
                          'xmlns:metadata'  => 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata',
        Severity: Minor
        Found in lib/odata/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 instantiate_property has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def instantiate_property(property_name, value)
              value_type = service.get_property_type(name, property_name)
              klass = ::OData::PropertyRegistry[value_type]
        
              if klass.nil? && value_type =~ /^#{namespace}\./
        Severity: Minor
        Found in lib/odata/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 each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def each(&block)
              per_page = @each_batch_size
              page = 0
        
              loop do
        Severity: Minor
        Found in lib/odata/entity_set.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 << 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/odata/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 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/odata/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 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
              value_type = property_xml.attributes['Type'].value
              property_options = {}
        
        
        Severity: Minor
        Found in lib/odata/service.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