saltstack/salt

View on GitHub
salt/states/mount.py

Summary

Maintainability
F
3 wks
Test Coverage

Function mounted has a Cognitive Complexity of 363 (exceeds 5 allowed). Consider refactoring.
Open

def mounted(name,
            device,
            fstype,
            mkmnt=False,
            opts='defaults',
Severity: Minor
Found in salt/states/mount.py - About 1 wk 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 mount.py has 1057 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Mounting of filesystems
=======================

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

    Cyclomatic complexity is too high in function mounted. (125)
    Open

    def mounted(name,
                device,
                fstype,
                mkmnt=False,
                opts='defaults',
    Severity: Minor
    Found in salt/states/mount.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 unmounted has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    def unmounted(name,
                  device=None,
                  config='/etc/fstab',
                  persist=False,
                  user=None,
    Severity: Minor
    Found in salt/states/mount.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

    Function swap has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    def swap(name, persist=True, config='/etc/fstab'):
        '''
        Activates a swap device
    
        .. code-block:: yaml
    Severity: Minor
    Found in salt/states/mount.py - About 6 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 fstab_present has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def fstab_present(name, fs_file, fs_vfstype, fs_mntops='defaults',
                      fs_freq=0, fs_passno=0, mount_by=None,
                      config='/etc/fstab', mount=True, match_on='auto',
                      not_change=False):
        '''Makes sure that a fstab mount point is pressent.
    Severity: Minor
    Found in salt/states/mount.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 fstab_absent has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def fstab_absent(name, fs_file, mount_by=None, config='/etc/fstab'):
        '''
        Makes sure that a fstab mount point is absent.
    
        name
    Severity: Minor
    Found in salt/states/mount.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Cyclomatic complexity is too high in function unmounted. (24)
    Open

    def unmounted(name,
                  device=None,
                  config='/etc/fstab',
                  persist=False,
                  user=None,
    Severity: Minor
    Found in salt/states/mount.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 function swap. (22)
    Open

    def swap(name, persist=True, config='/etc/fstab'):
        '''
        Activates a swap device
    
        .. code-block:: yaml
    Severity: Minor
    Found in salt/states/mount.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 _convert_to has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _convert_to(maybe_device, convert_to):
        '''
        Convert a device name, UUID or LABEL to a device name, UUID or
        LABEL.
    
    
    Severity: Minor
    Found in salt/states/mount.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Avoid deeply nested control flow statements.
    Open

                        if _device in active:
                            _real_device = active[_device]['device']
                            opts = list(set(opts + active[_device]['opts'] + active[_device]['superopts']))
                            active[real_name]['opts'].append('bind')
                            break
    Severity: Major
    Found in salt/states/mount.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if opt.split('=')[0] in mount_ignore_fs_keys.get(fstype, []):
                              opt = opt.split('=')[0]
      
                          # convert uid/gid to numeric value from user/group name
                          name_id_opts = {'uid': 'user.info',
      Severity: Major
      Found in salt/states/mount.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if real_name in active:
                                ret['comment'] = "Unable to unmount"
                                ret['result'] = None
                                return ret
                            update_mount_cache = True
        Severity: Major
        Found in salt/states/mount.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if opt.split('=')[0] in name_id_opts and len(opt.split('=')) > 1:
                                  _givenid = opt.split('=')[1]
                                  _param = opt.split('=')[0]
                                  _id = _givenid
                                  if not re.match('[0-9]+$', _givenid):
          Severity: Major
          Found in salt/states/mount.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if opt in mount_translate_options:
                                    opt = mount_translate_options[opt]
            
            
            Severity: Major
            Found in salt/states/mount.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if fstype in ['cifs'] and opt.split('=')[0] == 'user':
                                      opt = "username={0}".format(opt.split('=')[1])
              
              
              Severity: Major
              Found in salt/states/mount.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if real_device != device:
                                        ret['changes']['umount'] += " (" + real_device + ")"
                                    ret['changes']['umount'] += ", current: " + ', '.join(device_list)
                Severity: Major
                Found in salt/states/mount.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for _device in device_list:
                                          if re.match(regex, _device):
                                              _device_mismatch_is_ignored = _device
                                              break
                                  if _device_mismatch_is_ignored:
                  Severity: Major
                  Found in salt/states/mount.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if mount:
                                            comment = ('{0} is mounted, but its fstab entry '
                                                              'must be updated.').format(name)
                                        else:
                                            comment = ('The {0} fstab entry '
                    Severity: Major
                    Found in salt/states/mount.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if keyval_option in mount_invisible_keys:
                                              opt = keyval_option
                      
                      
                      Severity: Major
                      Found in salt/states/mount.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if size_match:
                                                converted_size = _size_convert(size_match)
                                                opt = "size={0}k".format(converted_size)
                                            # make cifs option user synonym for option username which is reported by /proc/mounts
                                            if fstype in ['cifs'] and opt.split('=')[0] == 'user':
                        Severity: Major
                        Found in salt/states/mount.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for _active_opt in _active_superopts:
                                                  size_match = re.match(r'size=(?P<size_value>[0-9]+)(?P<size_unit>k|m|g)', _active_opt)
                                                  if size_match:
                                                      converted_size = _size_convert(size_match)
                                                      opt = "size={0}k".format(converted_size)
                          Severity: Major
                          Found in salt/states/mount.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if _missing:
                                                    if __opts__['test']:
                                                        ret['result'] = None
                                                        ret['comment'] = ('Remount would be forced because'
                                                                          ' options ({0})'
                            Severity: Major
                            Found in salt/states/mount.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if opt not in active[real_name]['opts'] \
                                                  and opt not in _active_superopts \
                                                  and opt not in mount_invisible_options \
                                                  and opt not in mount_ignore_fs_keys.get(fstype, []) \
                                                  and opt not in mount_invisible_keys:
                              Severity: Major
                              Found in salt/states/mount.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if mount:
                                                        comment = ('{0} is mounted, but needs to be '
                                                                          'written to the fstab in order to be '
                                                                          'made persistent.').format(name)
                                                    else:
                                Severity: Major
                                Found in salt/states/mount.py - About 45 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

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

                                    Avoid too many return statements within this function.
                                    Open

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

                                      Avoid too many return statements within this function.
                                      Open

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

                                        Avoid too many return statements within this function.
                                        Open

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

                                          Avoid too many return statements within this function.
                                          Open

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

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

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

                                                Avoid too many return statements within this function.
                                                Open

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

                                                  Avoid too many return statements within this function.
                                                  Open

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

                                                    Avoid too many return statements within this function.
                                                    Open

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

                                                      Avoid too many return statements within this function.
                                                      Open

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

                                                        Avoid too many return statements within this function.
                                                        Open

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

                                                          Avoid too many return statements within this function.
                                                          Open

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

                                                            Avoid too many return statements within this function.
                                                            Open

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

                                                              Avoid too many return statements within this function.
                                                              Open

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

                                                                Avoid too many return statements within this function.
                                                                Open

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

                                                                  Avoid too many return statements within this function.
                                                                  Open

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

                                                                    Avoid too many return statements within this function.
                                                                    Open

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

                                                                      Avoid too many return statements within this function.
                                                                      Open

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

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

                                                                                                if __opts__['test']:
                                                                                                    ret['result'] = None
                                                                                                    ret['comment'] = ('Remount would be forced because'
                                                                                                                      ' options ({0})'
                                                                                                                      'changed'.format(','.join(_missing)))
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 1 other location - About 2 days to fix
                                                                        salt/states/mount.py on lines 450..469

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

                                                                        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 fstype in ['nfs', 'cvfs'] or fstype.startswith('fuse'):
                                                                                                        ret['changes']['umount'] = "Forced unmount and mount because " \
                                                                                                                                    + "options ({0}) changed".format(opt)
                                                                                                        unmount_result = __salt__['mount.umount'](real_name)
                                                                                                        if unmount_result is True:
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 1 other location - About 2 days to fix
                                                                        salt/states/mount.py on lines 480..508

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

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                                                if not re.match('[0-9]+$', _givenid):
                                                                                                    _info = __salt__[name_id_opts[_param]](_givenid)
                                                                                                    if _info and _param in _info:
                                                                                                        _id = _info[_param]
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 1 other location - About 3 hrs to fix
                                                                        salt/modules/mount.py on lines 226..229

                                                                        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

                                                                                                opts = list(set(opts + active[_device]['opts'] + active[_device]['superopts']))
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 1 other location - About 1 hr to fix
                                                                        salt/states/mount.py on lines 265..265

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

                                                                        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

                                                                                            opts = list(set(opts + active[_device]['opts'] + active[_device]['superopts']))
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 1 other location - About 1 hr to fix
                                                                        salt/states/mount.py on lines 257..257

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

                                                                        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 fs_mntops == 'defaults':
                                                                                if __grains__['os'] in ['MacOS', 'Darwin']:
                                                                                    fs_mntops = 'noowners'
                                                                                elif __grains__['os'] == 'AIX':
                                                                                    fs_mntops = ''
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 2 other locations - About 1 hr to fix
                                                                        salt/states/mount.py on lines 1091..1095
                                                                        salt/states/mount.py on lines 1232..1236

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

                                                                        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 config == '/etc/fstab':
                                                                                if __grains__['os'] in ['MacOS', 'Darwin']:
                                                                                    config = '/etc/auto_salt'
                                                                                elif __grains__['os'] == 'AIX':
                                                                                    config = '/etc/filesystems'
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 2 other locations - About 1 hr to fix
                                                                        salt/states/mount.py on lines 1084..1088
                                                                        salt/states/mount.py on lines 1091..1095

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

                                                                        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 config == '/etc/fstab':
                                                                                if __grains__['os'] in ['MacOS', 'Darwin']:
                                                                                    config = '/etc/auto_salt'
                                                                                elif __grains__['os'] == 'AIX':
                                                                                    config = '/etc/filesystems'
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 2 other locations - About 1 hr to fix
                                                                        salt/states/mount.py on lines 1084..1088
                                                                        salt/states/mount.py on lines 1232..1236

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

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                            elif out == 'new':
                                                                                ret['changes']['persist'] = out
                                                                                msg = '{} entry added in {}.'
                                                                                ret['comment'].append(msg.format(fs_file, config))
                                                                        Severity: Minor
                                                                        Found in salt/states/mount.py and 1 other location - About 55 mins to fix
                                                                        salt/states/mount.py on lines 1189..1192

                                                                        Duplicated Code

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

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

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

                                                                        Tuning

                                                                        This issue has a mass of 45.

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                            elif out == 'change':
                                                                                ret['changes']['persist'] = out
                                                                                msg = '{} entry updated in {}.'
                                                                                ret['comment'].append(msg.format(fs_file, config))
                                                                        Severity: Minor
                                                                        Found in salt/states/mount.py and 1 other location - About 55 mins to fix
                                                                        salt/states/mount.py on lines 1185..1188

                                                                        Duplicated Code

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

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

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

                                                                        Tuning

                                                                        This issue has a mass of 45.

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                                if out == 'change':
                                                                                    ret['changes']['persist'] = 'update'
                                                                                    ret['comment'] += '. Updated the entry in the fstab.'
                                                                                    return ret
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 3 other locations - About 45 mins to fix
                                                                        salt/states/mount.py on lines 715..718
                                                                        salt/states/mount.py on lines 719..722
                                                                        salt/states/mount.py on lines 815..818

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

                                                                        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

                                                                                if out == 'new':
                                                                                    ret['changes']['persist'] = 'new'
                                                                                    ret['comment'] += '. Added new entry to the fstab.'
                                                                                    return ret
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 3 other locations - About 45 mins to fix
                                                                        salt/states/mount.py on lines 719..722
                                                                        salt/states/mount.py on lines 815..818
                                                                        salt/states/mount.py on lines 819..822

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

                                                                        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

                                                                                if out == 'change':
                                                                                    ret['changes']['persist'] = 'update'
                                                                                    ret['comment'] += '. Updated the entry in the fstab.'
                                                                                    return ret
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 3 other locations - About 45 mins to fix
                                                                        salt/states/mount.py on lines 715..718
                                                                        salt/states/mount.py on lines 815..818
                                                                        salt/states/mount.py on lines 819..822

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

                                                                        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

                                                                                if out == 'new':
                                                                                    ret['changes']['persist'] = 'new'
                                                                                    ret['comment'] += '. Added new entry to the fstab.'
                                                                                    return ret
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 3 other locations - About 45 mins to fix
                                                                        salt/states/mount.py on lines 715..718
                                                                        salt/states/mount.py on lines 719..722
                                                                        salt/states/mount.py on lines 819..822

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

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

                                                                                elif __grains__['os'] == 'AIX':
                                                                                    out = __salt__['mount.set_filesystems'](name=fs_file,
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 8 other locations - About 35 mins to fix
                                                                        salt/states/boto_elasticache.py on lines 315..315
                                                                        salt/states/boto_iot.py on lines 687..687
                                                                        salt/states/boto_iot.py on lines 735..735
                                                                        salt/states/boto_lambda.py on lines 831..831
                                                                        salt/states/chocolatey.py on lines 421..421
                                                                        salt/states/csf.py on lines 93..93
                                                                        salt/states/mount.py on lines 1161..1171
                                                                        salt/states/postgres_cluster.py on lines 96..96

                                                                        Duplicated Code

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

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

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

                                                                        Tuning

                                                                        This issue has a mass of 41.

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                            elif __grains__['os'] == 'AIX':
                                                                                out = __salt__['mount.set_filesystems'](name=fs_file,
                                                                                                                        device=fs_spec,
                                                                                                                        fstype=fs_vfstype,
                                                                                                                        opts=fs_mntops,
                                                                        Severity: Major
                                                                        Found in salt/states/mount.py and 8 other locations - About 35 mins to fix
                                                                        salt/states/boto_elasticache.py on lines 315..315
                                                                        salt/states/boto_iot.py on lines 687..687
                                                                        salt/states/boto_iot.py on lines 735..735
                                                                        salt/states/boto_lambda.py on lines 831..831
                                                                        salt/states/chocolatey.py on lines 421..421
                                                                        salt/states/csf.py on lines 93..93
                                                                        salt/states/mount.py on lines 1117..1118
                                                                        salt/states/postgres_cluster.py on lines 96..96

                                                                        Duplicated Code

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

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

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

                                                                        Tuning

                                                                        This issue has a mass of 41.

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

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

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

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

                                                                        Refactorings

                                                                        Further Reading

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

                                                                                elif out == 'change':
                                                                                    msg = '{} entry will be updated in {}.'
                                                                                    ret['comment'].append(msg.format(fs_file, config))
                                                                                else:
                                                                                    ret['result'] = False
                                                                        Severity: Minor
                                                                        Found in salt/states/mount.py and 1 other location - About 30 mins to fix
                                                                        salt/states/mount.py on lines 1189..1196

                                                                        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