saltstack/salt

View on GitHub
salt/states/cmd.py

Summary

Maintainability
F
1 wk
Test Coverage

File cmd.py has 1089 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Execution of arbitrary commands
===============================

Severity: Major
Found in salt/states/cmd.py - About 2 days to fix

    Function mod_run_check has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def mod_run_check(cmd_kwargs, onlyif, unless, creates):
        '''
        Execute the onlyif and unless logic.
        Return a result dict if:
        * onlyif failed (onlyif != 0)
    Severity: Minor
    Found in salt/states/cmd.py - About 5 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 script has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def script(name,
               source=None,
               template=None,
               onlyif=None,
               unless=None,
    Severity: Minor
    Found in salt/states/cmd.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

    Cyclomatic complexity is too high in function script. (32)
    Open

    def script(name,
               source=None,
               template=None,
               onlyif=None,
               unless=None,
    Severity: Minor
    Found in salt/states/cmd.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 run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(name,
            onlyif=None,
            unless=None,
            creates=None,
            cwd=None,
    Severity: Minor
    Found in salt/states/cmd.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

    Cyclomatic complexity is too high in function run. (25)
    Open

    def run(name,
            onlyif=None,
            unless=None,
            creates=None,
            cwd=None,
    Severity: Minor
    Found in salt/states/cmd.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 _reinterpreted_state has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def _reinterpreted_state(state):
        '''
        Re-interpret the state returned by salt.state.run using our protocol.
        '''
        ret = state['changes']
    Severity: Minor
    Found in salt/states/cmd.py - About 2 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 mod_run_check. (23)
    Open

    def mod_run_check(cmd_kwargs, onlyif, unless, creates):
        '''
        Execute the onlyif and unless logic.
        Return a result dict if:
        * onlyif failed (onlyif != 0)
    Severity: Minor
    Found in salt/states/cmd.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 mod_watch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def mod_watch(name, **kwargs):
        '''
        Execute a cmd function based on a watch call
    
        .. note::
    Severity: Minor
    Found in salt/states/cmd.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

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

    def call(name,
             func,
             args=(),
             kws=None,
             onlyif=None,
    Severity: Minor
    Found in salt/states/cmd.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/cmd.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return {'comment': 'unless condition is true',
      Severity: Major
      Found in salt/states/cmd.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

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

          Avoid too many return statements within this function.
          Open

                  return {'comment': 'All files in creates exist',
          Severity: Major
          Found in salt/states/cmd.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return {'comment': 'unless condition is true',
            Severity: Major
            Found in salt/states/cmd.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return {'comment': '{0} exists'.format(creates),
              Severity: Major
              Found in salt/states/cmd.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

                                return {'name': name,
                    Severity: Major
                    Found in salt/states/cmd.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

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

                        Avoid too many return statements within this function.
                        Open

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

                          Avoid too many return statements within this function.
                          Open

                                      return call(name, func, **kwargs)
                          Severity: Major
                          Found in salt/states/cmd.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return {'name': name,
                            Severity: Major
                            Found in salt/states/cmd.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return _reinterpreted_state(ret) if stateful else ret
                              Severity: Major
                              Found in salt/states/cmd.py - About 30 mins to fix

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

                                    if not isinstance(stateful, list):
                                        stateful = stateful is True
                                    elif isinstance(stateful, list) and 'test_name' in stateful[0]:
                                        test_name = stateful[0]['test_name']
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 3 hrs to fix
                                salt/states/cmd.py on lines 1186..1189

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

                                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 isinstance(stateful, list):
                                        stateful = stateful is True
                                    elif isinstance(stateful, list) and 'test_name' in stateful[0]:
                                        test_name = stateful[0]['test_name']
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 3 hrs to fix
                                salt/states/cmd.py on lines 933..936

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

                                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 __opts__['test'] and not test_name:
                                        ret['result'] = None
                                        ret['comment'] = 'Command "{0}" would have been executed'.format(name)
                                        return _reinterpreted_state(ret) if stateful else ret
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 2 hrs to fix
                                salt/states/cmd.py on lines 1258..1262

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

                                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 __opts__['test'] and not test_name:
                                        ret['result'] = None
                                        ret['comment'] = 'Command \'{0}\' would have been ' \
                                                         'executed'.format(name)
                                        return _reinterpreted_state(ret) if stateful else ret
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 2 hrs to fix
                                salt/states/cmd.py on lines 968..971

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

                                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'] and cmd_all['retcode'] == 0 and ret['changes']:
                                        ret['result'] = None
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 1290..1291

                                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

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

                                    if __opts__['test'] and cmd_all['retcode'] == 0 and ret['changes']:
                                        ret['result'] = None
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 1003..1004

                                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

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

                                    if env is not None and not isinstance(env, (list, dict)):
                                        ret['comment'] = ('Invalidly-formatted \'env\' parameter. See '
                                                          'documentation.')
                                        return ret
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 1200..1203

                                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

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

                                    if cwd and not os.path.isdir(cwd):
                                        ret['comment'] = (
                                            'Desired working directory "{0}" '
                                            'is not available'
                                        ).format(cwd)
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 973..978

                                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

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

                                    if cwd and not os.path.isdir(cwd):
                                        ret['comment'] = (
                                            'Desired working directory "{0}" '
                                            'is not available'
                                        ).format(cwd)
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 1264..1269

                                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

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

                                    if env is not None and not isinstance(env, (list, dict)):
                                        ret['comment'] = ('Invalidly-formatted \'env\' parameter. See '
                                                          'documentation.')
                                        return ret
                                Severity: Major
                                Found in salt/states/cmd.py and 1 other location - About 1 hr to fix
                                salt/states/cmd.py on lines 942..945

                                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 2 locations. Consider refactoring.
                                Open

                                    elif kwargs['sfun'] == 'wait_script' or kwargs['sfun'] == 'script':
                                        if kwargs.get('stateful'):
                                            kwargs.pop('stateful')
                                            return _reinterpreted_state(script(name, **kwargs))
                                        return script(name, **kwargs)
                                Severity: Minor
                                Found in salt/states/cmd.py and 1 other location - About 40 mins to fix
                                salt/states/cmd.py on lines 1401..1405

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

                                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 kwargs['sfun'] in ('wait', 'run', 'watch'):
                                        if kwargs.get('stateful'):
                                            kwargs.pop('stateful')
                                            return _reinterpreted_state(run(name, **kwargs))
                                        return run(name, **kwargs)
                                Severity: Minor
                                Found in salt/states/cmd.py and 1 other location - About 40 mins to fix
                                salt/states/cmd.py on lines 1407..1411

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

                                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