rubyjedi/soap4r

View on GitHub
lib/soap/mapping/literalregistry.rb

Summary

Maintainability
D
2 days
Test Coverage

File literalregistry.rb has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'soap/baseData'
require 'soap/mapping/mapping'
require 'soap/mapping/typeMap'
require 'xsd/codegen/gensupport'
require 'xsd/namedelements'
Severity: Minor
Found in lib/soap/mapping/literalregistry.rb - About 4 hrs to fix

    Method stubobj2soap_elements has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def stubobj2soap_elements(obj, ele, definition, is_choice = false)
        added = false
        case definition
        when SchemaSequenceDefinition, SchemaEmptyDefinition
          definition.each do |eledef|
    Severity: Minor
    Found in lib/soap/mapping/literalregistry.rb - About 3 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 add_attributes2stubobj has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_attributes2stubobj(node, obj, definition)
        return if obj.nil? or node.extraattr.empty?
        if attributes = definition.attributes
          define_xmlattr(obj)
          attributes.each do |qname, class_name|
    Severity: Minor
    Found in lib/soap/mapping/literalregistry.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 stubobj2soap_elements has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def stubobj2soap_elements(obj, ele, definition, is_choice = false)
        added = false
        case definition
        when SchemaSequenceDefinition, SchemaEmptyDefinition
          definition.each do |eledef|
    Severity: Minor
    Found in lib/soap/mapping/literalregistry.rb - About 1 hr to fix

      Method add_elesoap2stubobj has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_elesoap2stubobj(node, obj, definition)
          vars = {}
          node.each do |name, value|
            item = definition.elements.find_element(value.elename)
            if item
      Severity: Minor
      Found in lib/soap/mapping/literalregistry.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 any2obj has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def any2obj(node, obj_class = nil)
          is_compound = node.is_a?(::SOAP::SOAPCompoundtype)
          # trust xsi:type first
          if is_compound and node.type
            definition = schema_definition_from_type(node.type)
      Severity: Minor
      Found in lib/soap/mapping/literalregistry.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 stubobj2soap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def stubobj2soap(obj, qname, definition)
          if obj.nil?
            ele = SOAPNil.new
            ele.elename = qname
          elsif obj.is_a?(::String)
      Severity: Minor
      Found in lib/soap/mapping/literalregistry.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 any2soap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def any2soap(obj, qname, obj_class)
          ele = nil
          if obj.is_a?(SOAP::Mapping::Object)
            return mappingobj2soap(obj, qname)
          end
      Severity: Minor
      Found in lib/soap/mapping/literalregistry.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 elesoapchild2obj has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def elesoapchild2obj(value, eledef)
          if eledef.mapped_class
            if eledef.mapped_class.include?(::SOAP::SOAPBasetype)
              base2obj(value, eledef.mapped_class)
            else
      Severity: Minor
      Found in lib/soap/mapping/literalregistry.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

      Avoid too many return statements within this method.
      Open

          return stubobj2soap(obj, qname, class_definition)
      Severity: Major
      Found in lib/soap/mapping/literalregistry.rb - About 30 mins to fix

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

          def obj2soap(obj, qname, obj_class = nil)
            soap_obj = nil
            if obj.is_a?(SOAPElement)
              soap_obj = obj
            else
        Severity: Minor
        Found in lib/soap/mapping/literalregistry.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

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

              if item and item.as_array?
                (vars[name] ||= []) << child
              elsif vars.key?(name)
                vars[name] = [vars[name], child].flatten
              else
        Severity: Minor
        Found in lib/soap/mapping/literalregistry.rb and 1 other location - About 25 mins to fix
        lib/soap/mapping/encodedregistry.rb on lines 516..522

        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

        There are no issues that match your filters.

        Category
        Status