saltstack/salt

View on GitHub
salt/modules/state.py

Summary

Maintainability
F
2 wks
Test Coverage

File state.py has 1879 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Control the state system on the minion.

State Caching
Severity: Major
Found in salt/modules/state.py - About 5 days to fix

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

    def sls(mods, test=None, exclude=None, queue=False, sync_mods=None, **kwargs):
        '''
        Execute the states in one or more SLS files
    
        test
    Severity: Minor
    Found in salt/modules/state.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

    Cyclomatic complexity is too high in function sls. (36)
    Open

    def sls(mods, test=None, exclude=None, queue=False, sync_mods=None, **kwargs):
        '''
        Execute the states in one or more SLS files
    
        test
    Severity: Minor
    Found in salt/modules/state.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 event has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def event(tagmatch='*',
              count=-1,
              quiet=False,
              sock_dir=None,
              pretty=False,
    Severity: Minor
    Found in salt/modules/state.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

    Function _disabled has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _disabled(funs):
        '''
        Return messages for disabled states
        that match state functions in funs.
        '''
    Severity: Minor
    Found in salt/modules/state.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

    Function pkg has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def pkg(pkg_path,
            pkg_sum,
            hash_type,
            test=None,
            **kwargs):
    Severity: Minor
    Found in salt/modules/state.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

    Function get_pauses has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_pauses(jid=None):
        '''
        Get a report on all of the currently paused state runs and pause
        run settings.
        Optionally send in a jid if you only desire to see a single pause
    Severity: Minor
    Found in salt/modules/state.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 highstate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def highstate(test=None, queue=False, **kwargs):
        '''
        Retrieve the state data from the salt master for this minion and execute it
    
        test
    Severity: Minor
    Found in salt/modules/state.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 clear_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def clear_request(name=None):
        '''
        .. versionadded:: 2015.5.0
    
        Clear out the state execution request without executing it
    Severity: Minor
    Found in salt/modules/state.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 sls_id has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def sls_id(id_, mods, test=None, queue=False, **kwargs):
        '''
        Call a single ID from the named module(s) and handle all requisites
    
        The state ID comes *before* the module ID(s) on the command line.
    Severity: Minor
    Found in salt/modules/state.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 pkg has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def pkg(pkg_path,
            pkg_sum,
            hash_type,
            test=None,
            **kwargs):
    Severity: Minor
    Found in salt/modules/state.py - About 1 hr to fix

      Function sls has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def sls(mods, test=None, exclude=None, queue=False, sync_mods=None, **kwargs):
          '''
          Execute the states in one or more SLS files
      
          test
      Severity: Minor
      Found in salt/modules/state.py - About 1 hr to fix

        Function sls_id has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def sls_id(id_, mods, test=None, queue=False, **kwargs):
            '''
            Call a single ID from the named module(s) and handle all requisites
        
            The state ID comes *before* the module ID(s) on the command line.
        Severity: Minor
        Found in salt/modules/state.py - About 1 hr to fix

          Function show_low_sls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def show_low_sls(mods, test=None, queue=False, **kwargs):
              '''
              Display the low data from a specific sls. The default environment is
              ``base``, use ``saltenv`` to specify a different environment.
          
          
          Severity: Minor
          Found in salt/modules/state.py - About 35 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

          Function run_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def run_request(name='default', **kwargs):
              '''
              .. versionadded:: 2015.5.0
          
              Execute the pending state request
          Severity: Minor
          Found in salt/modules/state.py - About 35 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

          Function show_sls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def show_sls(mods, test=None, queue=False, **kwargs):
              '''
              Display the state data from a specific sls or list of sls files on the
              master. The default environment is ``base``, use ``saltenv`` to specify a
              different environment.
          Severity: Minor
          Found in salt/modules/state.py - About 35 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

          Function _get_pause has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def _get_pause(jid, state_id=None):
              '''
              Return the pause information for a given jid
              '''
              pause_dir = os.path.join(__opts__['cachedir'], 'state_pause')
          Severity: Minor
          Found in salt/modules/state.py - About 35 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/modules/state.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

                          return lowstate
              Severity: Major
              Found in salt/modules/state.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return errors
                Severity: Major
                Found in salt/modules/state.py - About 30 mins to fix

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

                  def clear_cache():
                      '''
                      Clear out cached state files, forcing even cache runs to refresh the cache
                      on the next state execution.
                  
                  
                  Severity: Minor
                  Found in salt/modules/state.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

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

                  def top(topfn, test=None, queue=False, **kwargs):
                      '''
                      Execute a specific top file instead of the default. This is useful to apply
                      configurations from a different environment (for example, dev or prod), without
                      modifying the default top file.
                  Severity: Minor
                  Found in salt/modules/state.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

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

                  def disable(states):
                      '''
                      Disable state runs.
                  
                      CLI Example:
                  Severity: Minor
                  Found in salt/modules/state.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

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

                  def _get_test_value(test=None, **kwargs):
                      '''
                      Determine the correct value for the test flag.
                      '''
                      ret = True
                  Severity: Minor
                  Found in salt/modules/state.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

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

                  def template(tem, queue=False, **kwargs):
                      '''
                      Execute the information stored in a template file on the minion.
                  
                      This function does not ask a master for a SLS file to render but
                  Severity: Minor
                  Found in salt/modules/state.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

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

                  def enable(states):
                      '''
                      Enable state function or sls run
                  
                      CLI Example:
                  Severity: Minor
                  Found in salt/modules/state.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 2 locations. Consider refactoring.
                  Open

                  def clear_request(name=None):
                      '''
                      .. versionadded:: 2015.5.0
                  
                      Clear out the state execution request without executing it
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 1 day to fix
                  salt/client/ssh/wrapper/state.py on lines 593..632

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

                  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

                  def request(mods=None,
                              **kwargs):
                      '''
                      .. versionadded:: 2015.5.0
                  
                  
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 1 day to fix
                  salt/client/ssh/wrapper/state.py on lines 525..565

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

                  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

                  def run_request(name='default', **kwargs):
                      '''
                      .. versionadded:: 2015.5.0
                  
                      Execute the pending state request
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 1 day to fix
                  salt/client/ssh/wrapper/state.py on lines 635..663

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

                  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

                  def running(concurrent=False):
                      '''
                      Return a list of strings that contain state return data if a state function
                      is already running. This function is used to prevent multiple state calls
                      from being run at the same time.
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 6 hrs to fix
                  salt/client/ssh/wrapper/state.py on lines 270..297

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

                  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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     pillar_override,
                                                     kwargs.get('__pub_jid'),
                                                     pillar_enc=pillar_enc,
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 5 hrs to fix
                  salt/modules/state.py on lines 1300..1315

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

                  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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     pillar_override,
                                                     kwargs.get('__pub_jid'),
                                                     pillar_enc=pillar_enc,
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 5 hrs to fix
                  salt/modules/state.py on lines 1055..1070

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

                  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

                  def check_request(name=None):
                      '''
                      .. versionadded:: 2015.5.0
                  
                      Return the state request information, if any
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 5 hrs to fix
                  salt/client/ssh/wrapper/state.py on lines 568..590

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

                  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

                  def _prior_running_states(jid):
                      '''
                      Return a list of dicts of prior calls to state functions.  This function is
                      used to queue state calls so only one is run at a time.
                      '''
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 4 hrs to fix
                  salt/client/ssh/wrapper/state.py on lines 300..315

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

                  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

                  def _wait(jid):
                      '''
                      Wait for all previously started state jobs to finish running
                      '''
                      if jid is None:
                  Severity: Major
                  Found in salt/modules/state.py and 1 other location - About 3 hrs to fix
                  salt/client/ssh/wrapper/state.py on lines 121..130

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

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

                      try:
                          st_ = salt.state.State(opts,
                                                 pillar_override,
                                                 pillar_enc=pillar_enc,
                                                 proxy=__proxy__,
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 2 hrs to fix
                  salt/modules/state.py on lines 1508..1518
                  salt/modules/state.py on lines 1723..1733
                  salt/modules/state.py on lines 1919..1929

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     pillar_override,
                                                     pillar_enc=pillar_enc,
                                                     proxy=__proxy__,
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 2 hrs to fix
                  salt/modules/state.py on lines 1723..1733
                  salt/modules/state.py on lines 1919..1929
                  salt/modules/state.py on lines 2085..2095

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     pillar_override,
                                                     pillar_enc=pillar_enc,
                                                     proxy=__proxy__,
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 2 hrs to fix
                  salt/modules/state.py on lines 1508..1518
                  salt/modules/state.py on lines 1919..1929
                  salt/modules/state.py on lines 2085..2095

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     pillar_override,
                                                     pillar_enc=pillar_enc,
                                                     proxy=__proxy__,
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 2 hrs to fix
                  salt/modules/state.py on lines 1508..1518
                  salt/modules/state.py on lines 1723..1733
                  salt/modules/state.py on lines 2085..2095

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     proxy=__proxy__,
                                                     initial_pillar=_get_initial_pillar(opts))
                      except NameError:
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 1 hr to fix
                  salt/modules/state.py on lines 595..600
                  salt/modules/state.py on lines 1550..1556
                  salt/modules/state.py on lines 1626..1632

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

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     proxy=__proxy__,
                                                     initial_pillar=_get_initial_pillar(opts))
                      except NameError:
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 1 hr to fix
                  salt/modules/state.py on lines 595..600
                  salt/modules/state.py on lines 1550..1556
                  salt/modules/state.py on lines 2021..2026

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

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

                      try:
                          st_ = salt.state.State(opts,
                                                 proxy=__proxy__,
                                                 initial_pillar=_get_initial_pillar(opts))
                      except NameError:
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 1 hr to fix
                  salt/modules/state.py on lines 1550..1556
                  salt/modules/state.py on lines 1626..1632
                  salt/modules/state.py on lines 2021..2026

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

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

                      try:
                          st_ = salt.state.HighState(opts,
                                                     proxy=__proxy__,
                                                     initial_pillar=_get_initial_pillar(opts))
                      except NameError:
                  Severity: Major
                  Found in salt/modules/state.py and 3 other locations - About 1 hr to fix
                  salt/modules/state.py on lines 595..600
                  salt/modules/state.py on lines 1626..1632
                  salt/modules/state.py on lines 2021..2026

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

                  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

                      if os.path.exists(pause_path):
                          with salt.utils.files.fopen(pause_path, 'rb') as fp_:
                              data = salt.utils.msgpack.loads(fp_.read())
                  Severity: Major
                  Found in salt/modules/state.py and 2 other locations - About 1 hr to fix
                  salt/cloud/clouds/ec2.py on lines 1808..1810
                  salt/cloud/clouds/ec2.py on lines 4513..4515

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

                  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