saltstack/salt

View on GitHub
salt/states/azurearm_resource.py

Summary

Maintainability
F
1 wk
Test Coverage

File azurearm_resource.py has 648 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Azure (ARM) Resource State Module

.. versionadded:: 2019.2.0
Severity: Major
Found in salt/states/azurearm_resource.py - About 1 day to fix

    Function policy_definition_present has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    def policy_definition_present(name, policy_rule=None, policy_type=None, mode=None, display_name=None, description=None,
                                  metadata=None, parameters=None, policy_rule_json=None, policy_rule_file=None,
                                  template='jinja', source_hash=None, source_hash_name=None, skip_verify=False,
                                  connection_auth=None, **kwargs):
        '''
    Severity: Minor
    Found in salt/states/azurearm_resource.py - About 7 hrs 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

    Cyclomatic complexity is too high in function policy_definition_present. (47)
    Open

    def policy_definition_present(name, policy_rule=None, policy_type=None, mode=None, display_name=None, description=None,
                                  metadata=None, parameters=None, policy_rule_json=None, policy_rule_file=None,
                                  template='jinja', source_hash=None, source_hash_name=None, skip_verify=False,
                                  connection_auth=None, **kwargs):
        '''
    Severity: Minor
    Found in salt/states/azurearm_resource.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function policy_assignment_present has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def policy_assignment_present(name, scope, definition_name, display_name=None, description=None, assignment_type=None,
                                  parameters=None, connection_auth=None, **kwargs):
        '''
        .. versionadded:: 2019.2.0
    
    
    Severity: Minor
    Found in salt/states/azurearm_resource.py - About 3 hrs 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

    Consider simplifying this complex logical expression.
    Open

        if ((policy_rule_json or policy_rule_file) and
           (policy_type or mode or display_name or description or metadata or parameters)):
            ret['comment'] = 'Policy definitions cannot be passed when "policy_rule_json" or "policy_rule_file" is defined!'
            return ret
    
    
    Severity: Critical
    Found in salt/states/azurearm_resource.py - About 1 hr to fix

      Function resource_group_present has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def resource_group_present(name, location, managed_by=None, tags=None, connection_auth=None, **kwargs):
          '''
          .. versionadded:: 2019.2.0
      
          Ensure a resource group exists.
      Severity: Minor
      Found in salt/states/azurearm_resource.py - About 55 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

      Avoid too many return statements within this function.
      Open

              return ret
      Severity: Major
      Found in salt/states/azurearm_resource.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return ret
        Severity: Major
        Found in salt/states/azurearm_resource.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return ret
          Severity: Major
          Found in salt/states/azurearm_resource.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return ret
            Severity: Major
            Found in salt/states/azurearm_resource.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return ret
              Severity: Major
              Found in salt/states/azurearm_resource.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return ret
                Severity: Major
                Found in salt/states/azurearm_resource.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return ret
                  Severity: Major
                  Found in salt/states/azurearm_resource.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return ret
                    Severity: Major
                    Found in salt/states/azurearm_resource.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return ret
                      Severity: Major
                      Found in salt/states/azurearm_resource.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return ret
                        Severity: Major
                        Found in salt/states/azurearm_resource.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return ret
                          Severity: Major
                          Found in salt/states/azurearm_resource.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return ret
                            Severity: Major
                            Found in salt/states/azurearm_resource.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return ret
                              Severity: Major
                              Found in salt/states/azurearm_resource.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return ret
                                Severity: Major
                                Found in salt/states/azurearm_resource.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return ret
                                  Severity: Major
                                  Found in salt/states/azurearm_resource.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return ret
                                    Severity: Major
                                    Found in salt/states/azurearm_resource.py - About 30 mins to fix

                                      Function resource_group_absent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      def resource_group_absent(name, connection_auth=None):
                                          '''
                                          .. versionadded:: 2019.2.0
                                      
                                          Ensure a resource group does not exist in the current subscription.
                                      Severity: Minor
                                      Found in salt/states/azurearm_resource.py - About 25 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

                                      Similar blocks of code found in 9 locations. Consider refactoring.
                                      Open

                                      def policy_assignment_absent(name, scope, connection_auth=None):
                                          '''
                                          .. versionadded:: 2019.2.0
                                      
                                          Ensure a policy assignment does not exist in the provided scope.
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 8 other locations - About 2 days to fix
                                      salt/states/azurearm_compute.py on lines 266..326
                                      salt/states/azurearm_dns.py on lines 307..367
                                      salt/states/azurearm_network.py on lines 261..321
                                      salt/states/azurearm_network.py on lines 674..734
                                      salt/states/azurearm_network.py on lines 1481..1541
                                      salt/states/azurearm_network.py on lines 1730..1790
                                      salt/states/azurearm_network.py on lines 2050..2110
                                      salt/states/azurearm_network.py on lines 2254..2314

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 267.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 7 locations. Consider refactoring.
                                      Open

                                              if (display_name or '').lower() != policy.get('display_name', '').lower():
                                                  ret['changes']['display_name'] = {
                                                      'old': policy.get('display_name'),
                                                      'new': display_name
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 6 other locations - About 2 hrs to fix
                                      salt/states/azurearm_network.py on lines 938..941
                                      salt/states/azurearm_network.py on lines 945..948
                                      salt/states/azurearm_resource.py on lines 457..460
                                      salt/states/azurearm_resource.py on lines 463..466
                                      salt/states/azurearm_resource.py on lines 469..472
                                      salt/states/azurearm_resource.py on lines 692..695

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 7 locations. Consider refactoring.
                                      Open

                                              if (display_name or '').lower() != policy.get('display_name', '').lower():
                                                  ret['changes']['display_name'] = {
                                                      'old': policy.get('display_name'),
                                                      'new': display_name
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 6 other locations - About 2 hrs to fix
                                      salt/states/azurearm_network.py on lines 938..941
                                      salt/states/azurearm_network.py on lines 945..948
                                      salt/states/azurearm_resource.py on lines 457..460
                                      salt/states/azurearm_resource.py on lines 469..472
                                      salt/states/azurearm_resource.py on lines 686..689
                                      salt/states/azurearm_resource.py on lines 692..695

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 7 locations. Consider refactoring.
                                      Open

                                              if (mode or '').lower() != policy.get('mode', '').lower():
                                                  ret['changes']['mode'] = {
                                                      'old': policy.get('mode'),
                                                      'new': mode
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 6 other locations - About 2 hrs to fix
                                      salt/states/azurearm_network.py on lines 938..941
                                      salt/states/azurearm_network.py on lines 945..948
                                      salt/states/azurearm_resource.py on lines 463..466
                                      salt/states/azurearm_resource.py on lines 469..472
                                      salt/states/azurearm_resource.py on lines 686..689
                                      salt/states/azurearm_resource.py on lines 692..695

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 7 locations. Consider refactoring.
                                      Open

                                              if (description or '').lower() != policy.get('description', '').lower():
                                                  ret['changes']['description'] = {
                                                      'old': policy.get('description'),
                                                      'new': description
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 6 other locations - About 2 hrs to fix
                                      salt/states/azurearm_network.py on lines 938..941
                                      salt/states/azurearm_network.py on lines 945..948
                                      salt/states/azurearm_resource.py on lines 457..460
                                      salt/states/azurearm_resource.py on lines 463..466
                                      salt/states/azurearm_resource.py on lines 686..689
                                      salt/states/azurearm_resource.py on lines 692..695

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 7 locations. Consider refactoring.
                                      Open

                                              if (description or '').lower() != policy.get('description', '').lower():
                                                  ret['changes']['description'] = {
                                                      'old': policy.get('description'),
                                                      'new': description
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 6 other locations - About 2 hrs to fix
                                      salt/states/azurearm_network.py on lines 938..941
                                      salt/states/azurearm_network.py on lines 945..948
                                      salt/states/azurearm_resource.py on lines 457..460
                                      salt/states/azurearm_resource.py on lines 463..466
                                      salt/states/azurearm_resource.py on lines 469..472
                                      salt/states/azurearm_resource.py on lines 686..689

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                              if assignment_type and assignment_type.lower() != policy.get('type', '').lower():
                                                  ret['changes']['type'] = {
                                                      'old': policy.get('type'),
                                                      'new': assignment_type
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 1 other location - About 2 hrs to fix
                                      salt/states/azurearm_resource.py on lines 451..454

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                              if policy_type and policy_type.lower() != policy.get('policy_type', '').lower():
                                                  ret['changes']['policy_type'] = {
                                                      'old': policy.get('policy_type'),
                                                      'new': policy_type
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 1 other location - About 2 hrs to fix
                                      salt/states/azurearm_resource.py on lines 667..670

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 59.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 15 locations. Consider refactoring.
                                      Open

                                              if not ret['changes']:
                                                  ret['result'] = True
                                                  ret['comment'] = 'Policy assignment {0} is already present.'.format(name)
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 14 other locations - About 55 mins to fix
                                      salt/states/azurearm_compute.py on lines 215..218
                                      salt/states/azurearm_dns.py on lines 253..256
                                      salt/states/azurearm_dns.py on lines 557..560
                                      salt/states/azurearm_network.py on lines 211..214
                                      salt/states/azurearm_network.py on lines 418..421
                                      salt/states/azurearm_network.py on lines 628..631
                                      salt/states/azurearm_network.py on lines 987..990
                                      salt/states/azurearm_network.py on lines 1422..1425
                                      salt/states/azurearm_network.py on lines 1677..1680
                                      salt/states/azurearm_network.py on lines 1989..1992
                                      salt/states/azurearm_network.py on lines 2207..2210
                                      salt/states/azurearm_network.py on lines 2402..2405
                                      salt/states/azurearm_resource.py on lines 160..163
                                      salt/states/azurearm_resource.py on lines 487..490

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 45.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 15 locations. Consider refactoring.
                                      Open

                                              if not ret['changes']:
                                                  ret['result'] = True
                                                  ret['comment'] = 'Resource group {0} is already present.'.format(name)
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 14 other locations - About 55 mins to fix
                                      salt/states/azurearm_compute.py on lines 215..218
                                      salt/states/azurearm_dns.py on lines 253..256
                                      salt/states/azurearm_dns.py on lines 557..560
                                      salt/states/azurearm_network.py on lines 211..214
                                      salt/states/azurearm_network.py on lines 418..421
                                      salt/states/azurearm_network.py on lines 628..631
                                      salt/states/azurearm_network.py on lines 987..990
                                      salt/states/azurearm_network.py on lines 1422..1425
                                      salt/states/azurearm_network.py on lines 1677..1680
                                      salt/states/azurearm_network.py on lines 1989..1992
                                      salt/states/azurearm_network.py on lines 2207..2210
                                      salt/states/azurearm_network.py on lines 2402..2405
                                      salt/states/azurearm_resource.py on lines 487..490
                                      salt/states/azurearm_resource.py on lines 702..705

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 45.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 15 locations. Consider refactoring.
                                      Open

                                              if not ret['changes']:
                                                  ret['result'] = True
                                                  ret['comment'] = 'Policy definition {0} is already present.'.format(name)
                                                  return ret
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 14 other locations - About 55 mins to fix
                                      salt/states/azurearm_compute.py on lines 215..218
                                      salt/states/azurearm_dns.py on lines 253..256
                                      salt/states/azurearm_dns.py on lines 557..560
                                      salt/states/azurearm_network.py on lines 211..214
                                      salt/states/azurearm_network.py on lines 418..421
                                      salt/states/azurearm_network.py on lines 628..631
                                      salt/states/azurearm_network.py on lines 987..990
                                      salt/states/azurearm_network.py on lines 1422..1425
                                      salt/states/azurearm_network.py on lines 1677..1680
                                      salt/states/azurearm_network.py on lines 1989..1992
                                      salt/states/azurearm_network.py on lines 2207..2210
                                      salt/states/azurearm_network.py on lines 2402..2405
                                      salt/states/azurearm_resource.py on lines 160..163
                                      salt/states/azurearm_resource.py on lines 702..705

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 45.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 15 locations. Consider refactoring.
                                      Open

                                          if 'error' not in policy:
                                              ret['result'] = True
                                              ret['comment'] = 'Policy definition {0} has been created.'.format(name)
                                              return ret
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 14 other locations - About 35 mins to fix
                                      salt/modules/gpg.py on lines 904..907
                                      salt/states/azurearm_compute.py on lines 257..260
                                      salt/states/azurearm_dns.py on lines 298..301
                                      salt/states/azurearm_dns.py on lines 617..620
                                      salt/states/azurearm_network.py on lines 252..255
                                      salt/states/azurearm_network.py on lines 457..460
                                      salt/states/azurearm_network.py on lines 665..668
                                      salt/states/azurearm_network.py on lines 1046..1049
                                      salt/states/azurearm_network.py on lines 1472..1475
                                      salt/states/azurearm_network.py on lines 1721..1724
                                      salt/states/azurearm_network.py on lines 2041..2044
                                      salt/states/azurearm_network.py on lines 2245..2248
                                      salt/states/azurearm_network.py on lines 2441..2444
                                      salt/states/azurearm_resource.py on lines 747..750

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 41.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 15 locations. Consider refactoring.
                                      Open

                                          if 'error' not in policy:
                                              ret['result'] = True
                                              ret['comment'] = 'Policy assignment {0} has been created.'.format(name)
                                              return ret
                                      Severity: Major
                                      Found in salt/states/azurearm_resource.py and 14 other locations - About 35 mins to fix
                                      salt/modules/gpg.py on lines 904..907
                                      salt/states/azurearm_compute.py on lines 257..260
                                      salt/states/azurearm_dns.py on lines 298..301
                                      salt/states/azurearm_dns.py on lines 617..620
                                      salt/states/azurearm_network.py on lines 252..255
                                      salt/states/azurearm_network.py on lines 457..460
                                      salt/states/azurearm_network.py on lines 665..668
                                      salt/states/azurearm_network.py on lines 1046..1049
                                      salt/states/azurearm_network.py on lines 1472..1475
                                      salt/states/azurearm_network.py on lines 1721..1724
                                      salt/states/azurearm_network.py on lines 2041..2044
                                      salt/states/azurearm_network.py on lines 2245..2248
                                      salt/states/azurearm_network.py on lines 2441..2444
                                      salt/states/azurearm_resource.py on lines 538..541

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 41.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 3 locations. Consider refactoring.
                                      Open

                                          policy = __salt__['azurearm_resource.policy_definition_create_or_update'](
                                      Severity: Minor
                                      Found in salt/states/azurearm_resource.py and 2 other locations - About 30 mins to fix
                                      salt/states/azurearm_network.py on lines 1709..1709
                                      salt/states/kubernetes.py on lines 324..324

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 40.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status