saltstack/salt

View on GitHub
salt/utils/verify.py

Summary

Maintainability
F
1 wk
Test Coverage

Function verify_env has a Cognitive Complexity of 107 (exceeds 5 allowed). Consider refactoring.
Open

def verify_env(
        dirs,
        user,
        permissive=False,
        pki_dir='',
Severity: Minor
Found in salt/utils/verify.py - About 2 days 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

File verify.py has 498 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
A few checks to make sure the environment is sane
'''
from __future__ import absolute_import, print_function, unicode_literals
Severity: Minor
Found in salt/utils/verify.py - About 7 hrs to fix

    Function win_verify_env has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    def win_verify_env(
            path,
            dirs,
            permissive=False,
            pki_dir='',
    Severity: Minor
    Found in salt/utils/verify.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 verify_env. (37)
    Open

    def verify_env(
            dirs,
            user,
            permissive=False,
            pki_dir='',
    Severity: Minor
    Found in salt/utils/verify.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 verify_files has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def verify_files(files, user):
        '''
        Verify that the named files exist and are owned by the named user
        '''
        if salt.utils.platform.is_windows():
    Severity: Minor
    Found in salt/utils/verify.py - About 4 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 zmq_version has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def zmq_version():
        '''
        ZeroMQ python bindings >= 2.1.9 are required
        '''
        try:
    Severity: Minor
    Found in salt/utils/verify.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

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

    def check_user(user):
        '''
        Check user and assign process uid/gid.
        '''
        if salt.utils.platform.is_windows():
    Severity: Minor
    Found in salt/utils/verify.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 check_path_traversal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_path_traversal(path, user='root', skip_perm_errors=False):
        '''
        Walk from the root up to a directory and verify that the current
        user has access to read each directory. This is used for  making
        sure a user can read all parent directories of the minion's  key
    Severity: Minor
    Found in salt/utils/verify.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 verify_socket has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def verify_socket(interface, pub_port, ret_port):
        '''
        Attempt to bind to the sockets to verify that they are available
        '''
    
    
    Severity: Minor
    Found in salt/utils/verify.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 clean_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def clean_path(root, path, subdir=False):
        '''
        Accepts the root the path needs to be under and verifies that the path is
        under said root. Pass in subdir=True if the path can result in a
        subdirectory of the root instead of having to reside directly in the root
    Severity: Minor
    Found in salt/utils/verify.py - About 45 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 deeply nested control flow statements.
    Open

                        for name in files:
                            if name.startswith('.'):
                                continue
                            path = os.path.join(root, name)
                            try:
    Severity: Major
    Found in salt/utils/verify.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if is_console_configured():
                              log.critical(msg)
                          else:
                              sys.stderr.write("CRITICAL: {0}\n".format(msg))
      
      
      Severity: Major
      Found in salt/utils/verify.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for name in dirs:
                                path = os.path.join(root, name)
                                fmode = os.stat(path)
                                if fmode.st_uid != uid or fmode.st_gid != gid:
                                    if permissive and fmode.st_gid in groups:
        Severity: Major
        Found in salt/utils/verify.py - About 45 mins to fix

          Function check_max_open_files has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def check_max_open_files(opts):
              '''
              Check the number of max allowed open files and adjust if needed
              '''
              mof_c = opts.get('max_open_files', 100000)
          Severity: Minor
          Found in salt/utils/verify.py - About 45 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 False
          Severity: Major
          Found in salt/utils/verify.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

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

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

                            if fmode.st_uid != uid or fmode.st_gid != gid:
                                if permissive and fmode.st_gid in groups:
                                    # Allow the directory to be owned by any group root
                                    # belongs to if we say it's ok to be permissive
                                    pass
                Severity: Major
                Found in salt/utils/verify.py and 2 other locations - About 1 hr to fix
                salt/utils/verify.py on lines 268..273
                salt/utils/verify.py on lines 277..282

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 55.

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

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

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

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

                Refactorings

                Further Reading

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

                                        if fmode.st_uid != uid or fmode.st_gid != gid:
                                            if permissive and fmode.st_gid in groups:
                                                pass
                                            else:
                                                # chown the file for the new user
                Severity: Major
                Found in salt/utils/verify.py and 2 other locations - About 1 hr to fix
                salt/utils/verify.py on lines 247..254
                salt/utils/verify.py on lines 277..282

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 55.

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

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

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

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

                Refactorings

                Further Reading

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

                                        if fmode.st_uid != uid or fmode.st_gid != gid:
                                            if permissive and fmode.st_gid in groups:
                                                pass
                                            else:
                                                # chown the file for the new user
                Severity: Major
                Found in salt/utils/verify.py and 2 other locations - About 1 hr to fix
                salt/utils/verify.py on lines 247..254
                salt/utils/verify.py on lines 268..273

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 55.

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

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

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

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

                Refactorings

                Further Reading

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

                    try:
                        pwnam = pwd.getpwnam(user)
                        uid = pwnam[2]
                        gid = pwnam[3]
                        groups = salt.utils.user.get_gid_list(user, include_default=False)
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 156..163

                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

                    try:
                        pwnam = pwd.getpwnam(user)
                        uid = pwnam[2]
                    except KeyError:
                        err = ('Failed to prepare the Salt environment for user '
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 217..227

                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

                            try:
                                os.makedirs(dir_)
                            except OSError as err:
                                msg = 'Failed to create directory path "{0}" - {1}\n'
                                sys.stderr.write(msg.format(dir_, err))
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 232..241

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 40.

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

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

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

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

                Refactorings

                Further Reading

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

                            try:
                                with salt.utils.files.set_umask(0o022):
                                    os.makedirs(dir_)
                                # If starting the process as root, chown the new dirs
                                if os.getuid() == 0:
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 617..622

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 40.

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

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

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

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

                Refactorings

                Further Reading

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

                    if not match:
                        msg = "Using untested zmq python bindings version: '{0}'".format(ver)
                        if is_console_configured():
                            log.warning(msg)
                        else:
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 349..355

                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

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

                    except KeyError:
                        msg = 'User not found: "{0}"'.format(user)
                        if is_console_configured():
                            log.critical(msg)
                        else:
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 55..61

                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

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

                            try:
                                # Get a clean dacl by not passing an obj_name
                                dacl = salt.utils.win_dacl.dacl()
                
                                # Add aces to the dacl, use the GUID (locale non-specific)
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 573..583

                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

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

                        try:
                            # Make the Administrators group owner
                            # Use the SID to be locale agnostic
                            salt.utils.win_dacl.set_owner(path, 'S-1-5-32-544')
                
                
                Severity: Major
                Found in salt/utils/verify.py and 1 other location - About 1 hr to fix
                salt/utils/verify.py on lines 586..610

                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