wrstudios/odata4

View on GitHub
lib/odata4/entity.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

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

    There are no issues that match your filters.

    Category
    Status