fog/fog-azure-rm

View on GitHub
lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb

Summary

Maintainability
B
5 hrs
Test Coverage
F
25%

Method create_or_update_network_security_group has 119 lines of code (exceeds 25 allowed). Consider refactoring.
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

            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

              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?

      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

                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]

      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

      There are no issues that match your filters.

      Category
      Status