saltstack/salt

View on GitHub
salt/utils/win_dacl.py

Summary

Maintainability
F
3 wks
Test Coverage

File win_dacl.py has 1940 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
============
Windows DACL
============
Severity: Major
Found in salt/utils/win_dacl.py - About 5 days to fix

    Function _check_perms has a Cognitive Complexity of 219 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_perms(obj_name, obj_type, new_perms, cur_perms, access_mode, ret):
        '''
        Helper function used by ``check_perms`` for checking and setting Grant and
        Deny permissions.
    
    
    Severity: Minor
    Found in salt/utils/win_dacl.py - About 4 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 dacl has a Cognitive Complexity of 138 (exceeds 5 allowed). Consider refactoring.
    Open

    def dacl(obj_name=None, obj_type='file'):
        '''
        Helper function for instantiating a Dacl class.
    
        Args:
    Severity: Minor
    Found in salt/utils/win_dacl.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 check_perms has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_perms(obj_name,
                    obj_type='file',
                    ret=None,
                    owner=None,
                    grant_perms=None,
    Severity: Minor
    Found in salt/utils/win_dacl.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 _set_perms has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    def _set_perms(obj_dacl, obj_type, new_perms, cur_perms, access_mode):
        obj_type = obj_type.lower()
        ret = {}
        for user in new_perms:
            # Check that user exists:
    Severity: Minor
    Found in salt/utils/win_dacl.py - About 7 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 _check_perms. (45)
    Open

    def _check_perms(obj_name, obj_type, new_perms, cur_perms, access_mode, ret):
        '''
        Helper function used by ``check_perms`` for checking and setting Grant and
        Deny permissions.
    
    
    Severity: Minor
    Found in salt/utils/win_dacl.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 check_perms. (35)
    Open

    def check_perms(obj_name,
                    obj_type='file',
                    ret=None,
                    owner=None,
                    grant_perms=None,
    Severity: Minor
    Found in salt/utils/win_dacl.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 get_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_name(principal):
        '''
        Gets the name from the specified principal.
    
        Args:
    Severity: Minor
    Found in salt/utils/win_dacl.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 not has_permission(obj_name=obj_name,
                                              principal=user_name,
                                              permission=perm,
                                              access_mode=access_mode,
                                              obj_type=obj_type,
    Severity: Major
    Found in salt/utils/win_dacl.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not applies_to:
                              if obj_type.lower() in ['registry', 'registry32']:
                                  applies_to = 'this_key_subkeys'
                              else:
                                  applies_to = 'this_folder_subfolders_files'
      Severity: Major
      Found in salt/utils/win_dacl.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for perm in cur_perms['Not Inherited'][user_name][access_mode]['permissions']:
                                for flag in flags().ace_perms[obj_type]['basic']:
                                    if flags().ace_perms[obj_type]['basic'][flag] == perm:
                                        perm_flag = flag
                                        for flag1 in flags().ace_perms[obj_type]['basic']:
        Severity: Major
        Found in salt/utils/win_dacl.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for flag in flags().ace_prop[obj_type]:
                                  if flags().ace_prop[obj_type][flag] == cur_perms['Not Inherited'][user_name]['deny']['applies to']:
                                      at_flag = flag
                                      for flag1 in flags().ace_prop[obj_type]:
                                          if flags().ace_prop[obj_type][flag1] == at_flag:
          Severity: Major
          Found in salt/utils/win_dacl.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if __opts__['test'] is True:
                                    if 'remove_perms' not in ret['changes']:
                                        ret['changes']['remove_perms'] = {}
                                    ret['changes']['remove_perms'].update(
                                        {user_name: cur_perms['Not Inherited'][user_name]})
            Severity: Major
            Found in salt/utils/win_dacl.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if user_name in cur_perms['Not Inherited'] and \
                                          access_mode in cur_perms['Not Inherited'][user_name]:
                                      for flag in flags().ace_prop[obj_type]:
                                          if flags().ace_prop[obj_type][flag] == cur_perms['Not Inherited'][user_name][access_mode]['applies to']:
                                              at_flag = flag
              Severity: Major
              Found in salt/utils/win_dacl.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not perms:
                                        for perm in cur_perms['Not Inherited'][user_name][access_mode]['permissions']:
                                            for flag in flags().ace_perms[obj_type]['advanced']:
                                                if flags().ace_perms[obj_type]['advanced'][flag] == perm:
                                                    perm_flag = flag
                Severity: Major
                Found in salt/utils/win_dacl.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if __opts__['test'] is True:
                                          if 'remove_perms' not in ret['changes']:
                                              ret['changes']['remove_perms'] = {}
                                          ret['changes']['remove_perms'].update(
                                              {user_name: cur_perms['Not Inherited'][user_name]})
                  Severity: Major
                  Found in salt/utils/win_dacl.py - About 45 mins to fix

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

                    def has_permission(obj_name,
                                       principal,
                                       permission,
                                       access_mode='grant',
                                       obj_type='file',
                    Severity: Minor
                    Found in salt/utils/win_dacl.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 obj_type == 'file':
                                            applies_to = 'this_folder_subfolders_files'
                                        elif 'registry' in obj_type:
                                            applies_to = 'this_key_subkeys'
                                else:
                    Severity: Major
                    Found in salt/utils/win_dacl.py - About 45 mins to fix

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

                      def copy_security(source,
                                        target,
                                        obj_type='file',
                                        copy_owner=True,
                                        copy_group=True,
                      Severity: Minor
                      Found in salt/utils/win_dacl.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 user not in changes:
                                              changes[user] = {}
                                          changes[user][access_mode] = new_perms[user]['perms']
                      Severity: Major
                      Found in salt/utils/win_dacl.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if not cur_perms['Not Inherited'][user_name][access_mode]['applies to'] == applies_to_text:
                                                if user not in changes:
                                                    changes[user] = {}
                                                changes[user]['applies_to'] = applies_to
                        
                        
                        Severity: Major
                        Found in salt/utils/win_dacl.py - About 45 mins to fix

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

                          def get_primary_group(obj_name, obj_type='file'):
                              r'''
                              Gets the primary group of the passed object
                          
                              Args:
                          Severity: Minor
                          Found in salt/utils/win_dacl.py - About 35 mins to fix

                          Cognitive Complexity

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

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

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

                          Further reading

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

                          def get_owner(obj_name, obj_type='file'):
                              r'''
                              Gets the owner of the passed object
                          
                              Args:
                          Severity: Minor
                          Found in salt/utils/win_dacl.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 set_permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def set_permissions(obj_name,
                                              principal,
                                              permissions,
                                              access_mode='grant',
                                              applies_to=None,
                          Severity: Minor
                          Found in salt/utils/win_dacl.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 grant_perms is not None and \
                                              user_name.lower() not in set(k.lower() for k in grant_perms):
                                          if 'grant' in cur_perms['Not Inherited'][user_name]:
                                              if __opts__['test'] is True:
                                                  if 'remove_perms' not in ret['changes']:
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 2 days to fix
                          salt/utils/win_dacl.py on lines 2386..2403

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

                          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 deny_perms is not None and \
                                              user_name.lower() not in set(k.lower() for k in deny_perms):
                                          if 'deny' in cur_perms['Not Inherited'][user_name]:
                                              if __opts__['test'] is True:
                                                  if 'remove_perms' not in ret['changes']:
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 2 days to fix
                          salt/utils/win_dacl.py on lines 2367..2384

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

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

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

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

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

                          Refactorings

                          Further Reading

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

                              try:
                                  security_descriptor = win32security.GetNamedSecurityInfo(
                                      obj_name, obj_type_flag, win32security.GROUP_SECURITY_INFORMATION)
                                  primary_group_gid = security_descriptor.GetSecurityDescriptorGroup()
                          
                          
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 5 hrs to fix
                          salt/utils/win_dacl.py on lines 1252..1268

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

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

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

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

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

                          Refactorings

                          Further Reading

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

                              try:
                                  security_descriptor = win32security.GetNamedSecurityInfo(
                                      obj_name, obj_type_flag, win32security.OWNER_SECURITY_INFORMATION)
                                  owner_sid = security_descriptor.GetSecurityDescriptorOwner()
                          
                          
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 5 hrs to fix
                          salt/utils/win_dacl.py on lines 1337..1354

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

                          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

                                      for i in range(0, deny_obj_dacl.dacl.GetAceCount()):
                                          ace = deny_obj_dacl.dacl.GetAce(i)
                                          new_dacl.dacl.AddAccessDeniedAceEx(
                                              win32security.ACL_REVISION_DS,
                                              ace[0][1] ^ win32security.INHERITED_ACE,
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 801..807

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

                          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

                                      for i in range(0, allow_obj_dacl.dacl.GetAceCount()):
                                          ace = allow_obj_dacl.dacl.GetAce(i)
                                          new_dacl.dacl.AddAccessAllowedAceEx(
                                              win32security.ACL_REVISION_DS,
                                              ace[0][1] ^ win32security.INHERITED_ACE,
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 783..789

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

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

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

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

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

                          Refactorings

                          Further Reading

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

                              try:
                                  win32security.SetNamedSecurityInfo(
                                      obj_name,
                                      obj_flags.obj_type[obj_type.lower()],
                                      obj_flags.element['owner'],
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 1503..1512

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

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

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

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

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

                          Refactorings

                          Further Reading

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

                              try:
                                  win32security.SetNamedSecurityInfo(
                                      obj_name,
                                      obj_flags.obj_type[obj_type.lower()],
                                      obj_flags.element['group'],
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 1421..1431

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

                          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

                                      for i in range(0, deny_dacl.dacl.GetAceCount()):
                                          ace = deny_dacl.dacl.GetAce(i)
                                          new_dacl.dacl.AddAccessDeniedAceEx(
                                              win32security.ACL_REVISION_DS,
                                              ace[0][1],
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 792..798

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

                          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

                                      for i in range(0, allow_dacl.dacl.GetAceCount()):
                                          ace = allow_dacl.dacl.GetAce(i)
                                          new_dacl.dacl.AddAccessAllowedAceEx(
                                              win32security.ACL_REVISION_DS,
                                              ace[0][1],
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 3 hrs to fix
                          salt/utils/win_dacl.py on lines 774..780

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

                          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 user not in ret['changes']['perms']:
                                                  ret['changes']['perms'][user] = {}
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 1 hr to fix
                          salt/utils/win_dacl.py on lines 2134..2135

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 45.

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

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

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

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

                          Refactorings

                          Further Reading

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

                                          if user not in ret['changes']['perms']:
                                              ret['changes']['perms'][user] = {}
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 1 hr to fix
                          salt/utils/win_dacl.py on lines 2189..2190

                          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

                              if not ret:
                                  ret = {'name': obj_name,
                                         'changes': {},
                                         'comment': [],
                                         'result': True}
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 1 hr to fix
                          salt/modules/file.py on lines 4821..4829

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

                          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

                                              ret['changes']['perms'][user][access_mode] = changes[user][access_mode]
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 1 hr to fix
                          salt/utils/win_dacl.py on lines 2136..2136

                          Duplicated Code

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

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

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

                          Tuning

                          This issue has a mass of 41.

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

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

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

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

                          Refactorings

                          Further Reading

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

                                          ret['changes']['perms'][user][access_mode] = changes[user][access_mode]
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 1 other location - About 1 hr to fix
                          salt/utils/win_dacl.py on lines 2191..2191

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

                          def __virtual__():
                              '''
                              Only load if Win32 Libraries are installed
                              '''
                              if not salt.utils.platform.is_windows():
                          Severity: Major
                          Found in salt/utils/win_dacl.py and 6 other locations - About 1 hr to fix
                          salt/modules/win_lgpo.py on lines 4739..4747
                          salt/modules/win_service.py on lines 93..103
                          salt/modules/win_system.py on lines 50..60
                          salt/modules/win_useradd.py on lines 65..75
                          salt/utils/win_pdh.py on lines 60..70
                          salt/utils/win_reg.py on lines 60..73

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

                          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