fog/fog-azure-rm

View on GitHub
lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb

Summary

Maintainability
A
3 hrs
Test Coverage
F
29%

Method detach_data_disk_from_vm has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def detach_data_disk_from_vm(*)
          vm = {
            'location' => 'West US',
            'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
            'name' => 'fog-test-server',
Severity: Major
Found in lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb - About 2 hrs to fix

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

            def detach_data_disk_from_vm(resource_group, vm_name, disk_name, async)
              msg = "Detaching Data Disk #{disk_name} from Virtual Machine #{vm_name} in Resource Group #{resource_group}."
              Fog::Logger.debug msg
              vm = get_virtual_machine_instance(resource_group, vm_name)
              vm.storage_profile.data_disks.each_with_index do |disk, index|
    Severity: Minor
    Found in lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.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