lib/fog/cloudsigma/models/server.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method mount_volume has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

        def mount_volume(volume, device = 'virtio', dev_channel = nil, boot_order = nil)
          unless dev_channel
            specified_channels = self.volumes.map { |v| v.dev_channel }.sort
            if specified_channels
              controller, controller_channel = 0, 0
Severity: Minor
Found in lib/fog/cloudsigma/models/server.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 mount_volume has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def mount_volume(volume, device = 'virtio', dev_channel = nil, boot_order = nil)
          unless dev_channel
            specified_channels = self.volumes.map { |v| v.dev_channel }.sort
            if specified_channels
              controller, controller_channel = 0, 0
Severity: Minor
Found in lib/fog/cloudsigma/models/server.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                      if controller >= max_ctlr
                        raise Fog::CloudSigma::Errors::Error.new("Max channel reached, cannot attach more")
                      end
    Severity: Major
    Found in lib/fog/cloudsigma/models/server.rb - About 45 mins to fix

      Method add_nic has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def add_nic(vlan=nil, ip_v4_conf=nil, ip_v6_conf=nil, model='virtio', boot_order=nil)
      Severity: Minor
      Found in lib/fog/cloudsigma/models/server.rb - About 35 mins to fix

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

                def unmount_volume(volume_or_position)
                  if volume_or_position.kind_of? Fixnum
                    self.volumes.delete_at(volume_or_position)
                    # assign to update attributes
                    return self.volumes = self.volumes
        Severity: Minor
        Found in lib/fog/cloudsigma/models/server.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

        There are no issues that match your filters.

        Category
        Status