saltstack/salt

View on GitHub
salt/fileclient.py

Summary

Maintainability
F
1 wk
Test Coverage

File fileclient.py has 1160 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Classes that manage file clients
'''
from __future__ import absolute_import, print_function, unicode_literals
Severity: Major
Found in salt/fileclient.py - About 2 days to fix

    Function get_url has a Cognitive Complexity of 117 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_url(self, url, dest, makedirs=False, saltenv='base',
                    no_cache=False, cachedir=None, source_hash=None):
            '''
            Get a single file from a URL.
            '''
    Severity: Minor
    Found in salt/fileclient.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

    Function get_file has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_file(self,
                     path,
                     dest='',
                     makedirs=False,
                     saltenv='base',
    Severity: Minor
    Found in salt/fileclient.py - About 1 day 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 method get_url. (43)
    Open

        def get_url(self, url, dest, makedirs=False, saltenv='base',
                    no_cache=False, cachedir=None, source_hash=None):
            '''
            Get a single file from a URL.
            '''
    Severity: Minor
    Found in salt/fileclient.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

    Cyclomatic complexity is too high in method get_file. (42)
    Open

        def get_file(self,
                     path,
                     dest='',
                     makedirs=False,
                     saltenv='base',
    Severity: Minor
    Found in salt/fileclient.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 cache_dir has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def cache_dir(self, path, saltenv='base', include_empty=False,
                      include_pat=None, exclude_pat=None, cachedir=None):
            '''
            Download all of the files in a subdir of the master
            '''
    Severity: Minor
    Found in salt/fileclient.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

    Client has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Client(object):
        '''
        Base class for Salt file interactions
        '''
        def __init__(self, opts):
    Severity: Minor
    Found in salt/fileclient.py - About 3 hrs to fix

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

          def get_dir(self, path, dest='', saltenv='base', gzip=None,
                      cachedir=None):
              '''
              Get a directory recursively from the salt-master
              '''
      Severity: Minor
      Found in salt/fileclient.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 is_cached has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def is_cached(self, path, saltenv='base', cachedir=None):
              '''
              Returns the full path to a file if it is cached locally on the minion
              otherwise returns a blank string
              '''
      Severity: Minor
      Found in salt/fileclient.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 get_template has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_template(
                  self,
                  url,
                  dest,
                  template='jinja',
      Severity: Minor
      Found in salt/fileclient.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 list_states has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def list_states(self, saltenv):
              '''
              Return a list of all available sls modules on the master for a given
              environment
              '''
      Severity: Minor
      Found in salt/fileclient.py - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Avoid deeply nested control flow statements.
      Open

                                  with salt.utils.files.fopen(cache_dest, 'wb+') as ofile:
                                      ofile.write(data['data'])
                          if 'hsum' in data and d_tries < 3:
      Severity: Major
      Found in salt/fileclient.py - About 45 mins to fix

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

        def decode_dict_keys_to_str(src):
            '''
            Convert top level keys from bytes to strings if possible.
            This is necessary because Python 3 makes a distinction
            between these types.
        Severity: Minor
        Found in salt/fileclient.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

                                        if 'encoding' in field:
                                            encoding = field.split('encoding=')[-1]
                                    write_body[2] = encoding
        Severity: Major
        Found in salt/fileclient.py - About 45 mins to fix

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

              def hash_and_stat_file(self, path, saltenv='base'):
                  '''
                  The same as hash_file, but also return the file's mode, or None if no
                  mode data is present.
                  '''
          Severity: Minor
          Found in salt/fileclient.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

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

              def file_list_emptydirs(self, saltenv='base', prefix=''):
                  '''
                  List the empty dirs in the pillar_roots
                  with optional relative prefix path to limit directory traversal
                  '''
          Severity: Minor
          Found in salt/fileclient.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 _extrn_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _extrn_path(self, url, saltenv, cachedir=None):
                  '''
                  Return the extrn_filepath for a given url
                  '''
                  url_data = urlparse(url)
          Severity: Minor
          Found in salt/fileclient.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 dest
          Severity: Major
          Found in salt/fileclient.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return dest
            Severity: Major
            Found in salt/fileclient.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return ''.join(result)
              Severity: Major
              Found in salt/fileclient.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return ''
                Severity: Major
                Found in salt/fileclient.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return dest
                  Severity: Major
                  Found in salt/fileclient.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return dest
                    Severity: Major
                    Found in salt/fileclient.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return dest
                      Severity: Major
                      Found in salt/fileclient.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return dest
                        Severity: Major
                        Found in salt/fileclient.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return b''.join(result)
                          Severity: Major
                          Found in salt/fileclient.py - About 30 mins to fix

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

                                def file_list(self, saltenv='base', prefix=''):
                                    '''
                                    Return a list of files in the given environment
                                    with optional relative prefix path to limit directory traversal
                                    '''
                            Severity: Minor
                            Found in salt/fileclient.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

                                    if not salt.utils.platform.is_windows():
                                        hash_server, stat_server = self.hash_and_stat_file(path, saltenv)
                                        try:
                                            mode_server = stat_server[0]
                                        except (IndexError, TypeError):
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 3 hrs to fix
                            salt/fileclient.py on lines 1128..1137

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

                            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 salt.utils.platform.is_windows():
                                            hash_local, stat_local = \
                                                self.hash_and_stat_file(dest2check, saltenv)
                                            try:
                                                mode_local = stat_local[0]
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 3 hrs to fix
                            salt/fileclient.py on lines 1080..1088

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

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

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

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

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

                            Refactorings

                            Further Reading

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

                                    if cachedir is None:
                                        cachedir = self.opts['cachedir']
                                    elif not os.path.isabs(cachedir):
                                        cachedir = os.path.join(self.opts['cachedir'], cachedir)
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 3 hrs to fix
                            salt/fileclient.py on lines 806..809

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

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

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

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

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

                            Refactorings

                            Further Reading

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

                                    if cachedir is None:
                                        cachedir = self.opts['cachedir']
                                    elif not os.path.isabs(cachedir):
                                        cachedir = os.path.join(self.opts['cachedir'], cachedir)
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 3 hrs to fix
                            salt/fileclient.py on lines 162..165

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

                            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

                                def file_list_emptydirs(self, saltenv='base', prefix=''):
                                    '''
                                    List the empty dirs on the master
                                    '''
                                    load = {'saltenv': saltenv,
                            Severity: Major
                            Found in salt/fileclient.py and 3 other locations - About 2 hrs to fix
                            salt/fileclient.py on lines 1263..1271
                            salt/fileclient.py on lines 1283..1291
                            salt/fileclient.py on lines 1293..1301

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

                            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

                                def dir_list(self, saltenv='base', prefix=''):
                                    '''
                                    List the dirs on the master
                                    '''
                                    load = {'saltenv': saltenv,
                            Severity: Major
                            Found in salt/fileclient.py and 3 other locations - About 2 hrs to fix
                            salt/fileclient.py on lines 1263..1271
                            salt/fileclient.py on lines 1273..1281
                            salt/fileclient.py on lines 1293..1301

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

                            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

                                def file_list(self, saltenv='base', prefix=''):
                                    '''
                                    List the files on the master
                                    '''
                                    load = {'saltenv': saltenv,
                            Severity: Major
                            Found in salt/fileclient.py and 3 other locations - About 2 hrs to fix
                            salt/fileclient.py on lines 1273..1281
                            salt/fileclient.py on lines 1283..1291
                            salt/fileclient.py on lines 1293..1301

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

                            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

                                def symlink_list(self, saltenv='base', prefix=''):
                                    '''
                                    List symlinked files and dirs on the master
                                    '''
                                    load = {'saltenv': saltenv,
                            Severity: Major
                            Found in salt/fileclient.py and 3 other locations - About 2 hrs to fix
                            salt/fileclient.py on lines 1263..1271
                            salt/fileclient.py on lines 1273..1281
                            salt/fileclient.py on lines 1283..1291

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 64.

                            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 envs(self):
                                    '''
                                    Return a list of available environments
                                    '''
                                    load = {'cmd': '_file_envs'}
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 1 hr to fix
                            salt/fileclient.py on lines 1378..1384

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

                                def master_opts(self):
                                    '''
                                    Return the master opts data
                                    '''
                                    load = {'cmd': '_master_opts'}
                            Severity: Major
                            Found in salt/fileclient.py and 1 other location - About 1 hr to fix
                            salt/fileclient.py on lines 1370..1376

                            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 url_scheme and url_scheme.lower() in string.ascii_lowercase:
                                        url_path = ':'.join((url_scheme, url_path))
                                        url_scheme = 'file'
                            Severity: Minor
                            Found in salt/fileclient.py and 2 other locations - About 30 mins to fix
                            salt/modules/file.py on lines 4461..4463
                            salt/states/archive.py on lines 797..800

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 40.

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

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

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

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

                            Refactorings

                            Further Reading

                            There are no issues that match your filters.

                            Category
                            Status