saltstack/salt

View on GitHub
salt/states/win_dns_client.py

Summary

Maintainability
F
4 days
Test Coverage

Function dns_exists has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

def dns_exists(name, servers=None, interface='Local Area Connection', replace=False):
    '''
    Configure the DNS server list in the specified interface

    Example:
Severity: Minor
Found in salt/states/win_dns_client.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

Function primary_suffix has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def primary_suffix(name,
        suffix=None,
        updates=False):
    '''
    .. versionadded:: 2014.7.0
Severity: Minor
Found in salt/states/win_dns_client.py - About 1 hr 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 deeply nested control flow statements.
Open

                    if configured_list.index(server) != i:
                        ret['changes']['Servers Reordered'].append(server)
                else:
Severity: Major
Found in salt/states/win_dns_client.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not __salt__['win_dns_client.rm_dns'](server, interface):
                            ret['comment'] = (
                                    'Failed to remove {0} from DNS server list').format(server)
                            ret['result'] = False
                            return ret
    Severity: Major
    Found in salt/states/win_dns_client.py - About 45 mins to fix

      Avoid too many return statements within this function.
      Open

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

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

            updates_result = __utils__['reg.set_value'](
                    reg_data['updates']['hive'],
                    reg_data['updates']['key'],
                    reg_data['updates']['vname'],
                    reg_data['updates']['new'],
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 3 hrs to fix
        salt/states/win_dns_client.py on lines 238..243

        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 79.

        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

            suffix_result = __utils__['reg.set_value'](
                    reg_data['suffix']['hive'],
                    reg_data['suffix']['key'],
                    reg_data['suffix']['vname'],
                    reg_data['suffix']['new'],
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 3 hrs to fix
        salt/states/win_dns_client.py on lines 245..250

        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 79.

        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

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

                if __opts__['test']:
                    if server in configured_list:
                        if configured_list.index(server) != i:
                            ret['changes']['Servers Reordered'].append(server)
                    else:
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 3 hrs to fix
        salt/states/win_dns_client.py on lines 64..76

        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 69.

        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

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

                    if not __salt__['win_dns_client.add_dns'](server, interface, i + 1):
                        ret['comment'] = (
                                'Failed to add {0} as DNS server number {1}'
                                ).format(server, i + 1)
                        ret['result'] = False
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 3 hrs to fix
        salt/states/win_dns_client.py on lines 57..62

        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 69.

        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 reg_data['updates']['new'] != reg_data['updates']['old']:
                    ret['comment'] = 'Updated primary DNS suffix ({0}) and {1} suffix updates'.format(suffix, updates_operation)
                    ret['changes'] = {
                            'old': {
                                'suffix': reg_data['suffix']['old'],
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 2 hrs to fix
        salt/states/win_dns_client.py on lines 207..216

        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 67.

        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 reg_data['updates']['new'] == reg_data['updates']['old']:
                    return ret
                # Changes to update policy needed
                else:
                    ret['comment'] = '{0} suffix updates'.format(updates_operation)
        Severity: Major
        Found in salt/states/win_dns_client.py and 1 other location - About 2 hrs to fix
        salt/states/win_dns_client.py on lines 220..236

        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 67.

        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

            reg_data['suffix']['old'] = __utils__['reg.read_value'](
                    reg_data['suffix']['hive'],
                    reg_data['suffix']['key'],
                    reg_data['suffix']['vname'],)['vdata']
        Severity: Major
        Found in salt/states/win_dns_client.py and 2 other locations - About 1 hr to fix
        salt/modules/win_lgpo.py on lines 7697..7700
        salt/states/win_dns_client.py on lines 197..200

        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 55.

        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

            reg_data['updates']['old'] = bool(__utils__['reg.read_value'](
                    reg_data['updates']['hive'],
                    reg_data['updates']['key'],
                    reg_data['updates']['vname'],)['vdata'])
        Severity: Major
        Found in salt/states/win_dns_client.py and 2 other locations - About 1 hr to fix
        salt/modules/win_lgpo.py on lines 7697..7700
        salt/states/win_dns_client.py on lines 192..195

        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 55.

        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