Method create_or_update__virtual_network
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_or_update__virtual_network(*)
virtual_network = {
'id' => '/subscriptions/########-####-####-####-############/resourceGroups/fog-rg/providers/Microsoft.Network/virtualNetworks/fog-vnet',
'name' => 'fog-vnet',
'type' => 'Microsoft.Network/virtualNetworks',
Method create_or_update_virtual_network
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_or_update_virtual_network(resource_group_name, virtual_network_name, location, dns_servers, subnets, address_prefixes, tags)
Method define_vnet_object
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
Method define_subnet_objects
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def define_subnet_objects(subnets)
subnet_objects = []
subnets.each do |subnet|
network_security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
network_security_group.id = subnet[:network_security_group_id]
- 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 define_vnet_object
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def define_vnet_object(location, address_prefixes, dns_servers, subnets, tags)
virtual_network = Azure::ARM::Network::Models::VirtualNetwork.new
virtual_network.location = location
virtual_network.tags = tags
- 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
Move address_space = Azure::ARM::Network::Models::AddressSpace.new
out of the conditional. Open
address_space = Azure::ARM::Network::Models::AddressSpace.new
- Read upRead up
- Exclude checks
This cop checks for identical lines at the beginning or end of each branch of a conditional statement.
Example:
# bad
if condition
do_x
do_z
else
do_y
do_z
end
# good
if condition
do_x
else
do_y
end
do_z
# bad
if condition
do_z
do_x
else
do_z
do_y
end
# good
do_z
if condition
do_x
else
do_y
end
# bad
case foo
when 1
do_x
when 2
do_x
else
do_x
end
# good
case foo
when 1
do_x
do_y
when 2
# nothing
else
do_x
do_z
end
Move address_space = Azure::ARM::Network::Models::AddressSpace.new
out of the conditional. Open
address_space = Azure::ARM::Network::Models::AddressSpace.new
- Read upRead up
- Exclude checks
This cop checks for identical lines at the beginning or end of each branch of a conditional statement.
Example:
# bad
if condition
do_x
do_z
else
do_y
do_z
end
# good
if condition
do_x
else
do_y
end
do_z
# bad
if condition
do_z
do_x
else
do_z
do_y
end
# good
do_z
if condition
do_x
else
do_y
end
# bad
case foo
when 1
do_x
when 2
do_x
else
do_x
end
# good
case foo
when 1
do_x
do_y
when 2
# nothing
else
do_x
do_z
end
%w
-literals should be delimited by [
and ]
. Open
%w(10.1.0.0/16 10.2.0.0/16)
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)