ManageIQ/azure-armrest

View on GitHub
lib/azure/armrest/virtual_machine_service.rb

Summary

Maintainability
C
1 day
Test Coverage
F
28%

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

      def delete_unmanaged_storage(vm, options)
        sas = Azure::Armrest::StorageAccountService.new(configuration)

        storage_account = sas.get_from_vm(vm)

Severity: Minor
Found in lib/azure/armrest/virtual_machine_service.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

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

    class VirtualMachineService < ResourceGroupBasedService
      # Create and return a new VirtualMachineService instance. Most
      # methods for a VirtualMachineService instance will return one or more
      # VirtualMachine instances.
      #
Severity: Minor
Found in lib/azure/armrest/virtual_machine_service.rb - About 2 hrs to fix

    Method delete_associated_nics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def delete_associated_nics(vm, options)
            nis = Azure::Armrest::Network::NetworkInterfaceService.new(configuration)
            nics = vm.properties.network_profile.network_interfaces.map(&:id)
    
            if options[:ip_addresses]
    Severity: Minor
    Found in lib/azure/armrest/virtual_machine_service.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 delete_unmanaged_storage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def delete_unmanaged_storage(vm, options)
            sas = Azure::Armrest::StorageAccountService.new(configuration)
    
            storage_account = sas.get_from_vm(vm)
    
    
    Severity: Minor
    Found in lib/azure/armrest/virtual_machine_service.rb - About 1 hr to fix

      Method delete_associated_nics has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def delete_associated_nics(vm, options)
              nis = Azure::Armrest::Network::NetworkInterfaceService.new(configuration)
              nics = vm.properties.network_profile.network_interfaces.map(&:id)
      
              if options[:ip_addresses]
      Severity: Minor
      Found in lib/azure/armrest/virtual_machine_service.rb - About 1 hr to fix

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

              def delete_associated_resources(vmname, vmgroup, options = {})
                options = {
                  :network_interfaces      => true,
                  :ip_addresses            => true,
                  :os_disk                 => true,
        Severity: Minor
        Found in lib/azure/armrest/virtual_machine_service.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 delete_and_wait has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def delete_and_wait(service, name, group, options)
                resource_type = service.class.to_s.sub('Service', '').split('::').last
        
                log("Deleting #{resource_type} #{name}/#{group}") if options[:verbose]
        
        
        Severity: Minor
        Found in lib/azure/armrest/virtual_machine_service.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

        Avoid more than 3 levels of block nesting.
        Open

                      break if disk.x_ms_lease_status.casecmp('unlocked') != 0

        Checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        There are no issues that match your filters.

        Category
        Status