lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb
Method attach_data_disk_to_vm
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def attach_data_disk_to_vm(*)
vm = {
'location' => 'West US',
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/Microsoft.Compute/virtualMachines/fog-test-server',
'name' => 'fog-test-server',
Method attach_data_disk_to_vm
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def attach_data_disk_to_vm(disk_params, async)
# Variable un-packing for easy access
vm_name = disk_params[:vm_name]
vm_resource_group = disk_params[:vm_resource_group]
disk_name = disk_params[:disk_name]
Method attach_data_disk_to_vm
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def attach_data_disk_to_vm(disk_params, async)
# Variable un-packing for easy access
vm_name = disk_params[:vm_name]
vm_resource_group = disk_params[:vm_resource_group]
disk_name = disk_params[:disk_name]
- Read upRead up
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 get_unmanaged_disk_object
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def get_unmanaged_disk_object(disk_name, disk_size, lun, storage_account_name, access_key)
Use 2 (not 0) spaces for indentation. Open
Open
raise_azure_exception(e, msg)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end