lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb
Method create_or_update_network_security_group
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules)
network_security_group = {
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group_name}/providers/Microsoft.Network/networkSecurityGroups/#{security_group_name}",
'name' => security_group_name,
'type' => 'Microsoft.Network/networkSecurityGroups',
Method create_or_update_network_security_group
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_or_update_network_security_group(resource_group_name, security_group_name, location, security_rules, tags)
Method get_security_rule_objects
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_security_rule_objects(security_rules)
rules = []
security_rules.each do |sr|
security_rule = Azure::ARM::Network::Models::SecurityRule.new
security_rule.description = sr[:description] unless sr[:description].nil?
- 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
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
Open
security_rules.each do |sr|
security_rule = Azure::ARM::Network::Models::SecurityRule.new
security_rule.description = sr[:description] unless sr[:description].nil?
security_rule.protocol = sr[:protocol]
security_rule.source_port_range = sr[:source_port_range]
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond