cloudfoundry-community/bosh-cloudstack-cpi

View on GitHub
bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb

Summary

Maintainability
D
2 days
Test Coverage

Method serialize has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

      def serialize(value, info, default_namespace = @default_namespace)
        return unless VmomiSupport.is_child_version(@version, info.version)

        if value.nil?
          return if info.optional?
Severity: Minor
Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 1 day 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 serialize has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def serialize(value, info, default_namespace = @default_namespace)
        return unless VmomiSupport.is_child_version(@version, info.version)

        if value.nil?
          return if info.optional?
Severity: Major
Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 4 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                if value.class.respond_to?(:item)
                  item_type = value.class.item
                else
                  item_type = value.first.class
                end
    Severity: Major
    Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if info.type == Object
                  attribute += " #{@xsi_prefix}type=\"#{@xsd_prefix}string\""
                end
      Severity: Major
      Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if DYNAMIC_TYPES.include?(item_type)
                      tag = "string"
                      type = String::TypedArray
                    elsif item_type.ancestors.include?(Vmodl::ManagedObject)
                      tag = "ManagedObjectReference"
        Severity: Major
        Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 45 mins to fix

          Method serialize_data_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def serialize_data_object(value, info, attribute, current_default_namespace)
                  dynamic_type = VmomiSupport.compatible_type(value.class, @version)
                  if dynamic_type != info.type
                    namespace_attribute, qualified_name = qualified_name(dynamic_type, current_default_namespace)
                    attribute += "#{namespace_attribute} #{@xsi_prefix}type=\"#{qualified_name}\""
          Severity: Minor
          Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.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 deeply nested control flow statements.
          Open

                  elsif value.kind_of?(Vmodl::MethodName)
                    if info.type == Object
                      attribute += " #{@xsi_prefix}type=\"#{@xsd_prefix}string\""
                    end
                    @writer << "<#{info.wsdl_name}#{attribute}>#{value}</#{info.wsdl_name}>"
          Severity: Major
          Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb - About 45 mins to fix

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

                  def qualified_name(type, default_namespace)
                    attribute = ""
                    namespace, name = VmomiSupport.qualified_wsdl_name(type)
                    if namespace == default_namespace
                      prefix = ""
            Severity: Minor
            Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(writer, version, namespace_map)
                    @writer = writer
                    @version = version
                    @namespace_map = namespace_map
            
            
            Severity: Minor
            Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.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

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

                      if info.type == Object
                        namespace_attribute, qualified_name = qualified_name(value.class, current_default_namespace)
                        attribute += "#{namespace_attribute} #{@xsi_prefix}type=\"#{qualified_name}\""
                      end
            Severity: Minor
            Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb and 2 other locations - About 20 mins to fix
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 137..140
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 149..152

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

            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

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

                      if info.type == Object
                        namespace_attribute, qualified_name = qualified_name(value.class, current_default_namespace)
                        attribute += "#{namespace_attribute} #{@xsi_prefix}type=\"#{qualified_name}\""
                      end
            Severity: Minor
            Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb and 2 other locations - About 20 mins to fix
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 137..140
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 143..146

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

            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

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

                      if info.type == Object
                        namespace_attribute, qualified_name = qualified_name(value.class, current_default_namespace)
                        attribute += "#{namespace_attribute} #{@xsi_prefix}type=\"#{qualified_name}\""
                      end
            Severity: Minor
            Found in bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb and 2 other locations - About 20 mins to fix
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 143..146
            bosh_vsphere_cpi/lib/ruby_vim_sdk/soap/serializer.rb on lines 149..152

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

            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