gecos-team/gecoscc-ui

View on GitHub
gecoscc/utils.py

Summary

Maintainability
F
1 mo
Test Coverage

File utils.py has 1980 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

#
# Copyright 2013, Junta de Andalucia
# http://www.juntadeandalucia.es/
Severity: Major
Found in gecoscc/utils.py - About 5 days to fix

    Function move_in_inheritance has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
    Open

    def move_in_inheritance(logger, db, obj, inheritanceTree):
        """Move an object to another position in the inheritance Tree.
    
        Args:
            logger (object): Logger.
    Severity: Minor
    Found in gecoscc/utils.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 calculate_initial_inheritance_for_node has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

    def calculate_initial_inheritance_for_node(logger, db, node):
        """Function that calculates the initial "inheritance" field of a node.
    
        Args:
            logger (object): Logger.
    Severity: Minor
    Found in gecoscc/utils.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 remove_chef_user_data has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_chef_user_data(user, computers, api, policy_fields=None):
        '''
        Remove computer policies in chef node
        '''
        settings = get_current_registry().settings
    Severity: Minor
    Found in gecoscc/utils.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

    Function apply_change_in_inheritance has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

    def apply_change_in_inheritance(logger, db, action, obj, policy, node, inheritanceTree):
        """Function that looks for the node that received the change (obj) inside the inheritance tree
           and performs the change in its policies.
    
        Args:
    Severity: Minor
    Found in gecoscc/utils.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

    Function add_group_to_inheritance_tree has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_group_to_inheritance_tree(logger, db, group, inheritanceTree):
        """Function that adds a group to the inheritance tree of an object.
    
        Args:
            logger (object): Logger.
    Severity: Minor
    Found in gecoscc/utils.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

    Function move_in_inheritance_and_recalculate_policies has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    def move_in_inheritance_and_recalculate_policies(logger, db, srcobj, obj):
        """Move an object to another position in the inheritance Tree and recalculate
           the policies of the added nodes.
    
        Args:
    Severity: Minor
    Found in gecoscc/utils.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

    Function remove_chef_computer_data has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_chef_computer_data(computer, api, policies=None):
        '''
        Remove computer policies in chef node
        '''
        node_chef_id = computer.get('node_chef_id', None)
    Severity: Minor
    Found in gecoscc/utils.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function _nested_lookup has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def _nested_lookup(key, document):
        """Lookup a key in a nested document, yield a value"""
        from six import iteritems
    
        if isinstance(document, list):
    Severity: Minor
    Found in gecoscc/utils.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function apply_policies_to_emitter_object has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api=None, initialize=False, use_celery=True, policies_collection=None):
        '''
        Checks if a emitter object is within the scope of the objects that is related and then update policies
        '''
        from gecoscc.tasks import object_changed, object_created
    Severity: Minor
    Found in gecoscc/utils.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 visibility_object_related has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def visibility_object_related(db, obj):
        policies = obj.get('policies', None)
        if not policies:
            return obj
        emitter_policies = db.policies.find({'is_emitter_policy': True})
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def recalculate_inheritance_for_node(logger, db, action, obj, policy, node):
        """Function that recalculate the "inheritance" field of a node by changing or deleting a policy in
        a related node.
    
        Args:
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function recalculate_path_values has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def recalculate_path_values(logger, inheritanceTree, path_value, main_ou_list):
        """Recalculate the 'path' value in every node in the inheritance Tree.
    
        Args:
            logger (object): Logger.
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function remove_group_from_inheritance_tree has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_group_from_inheritance_tree(logger, db, group, inheritanceTree):
        """Function that remove a group from the inheritance tree of an object.
    
        Args:
            logger (object): Logger.
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function get_inheritance_tree_policies_list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_inheritance_tree_policies_list(inheritanceTree, policies_list):
        """Function that retuns a list with all the policies of all nodes in an inheritance Tree.
    
        Args:
            inheritanceTree (object): Tree of inheritance objects
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def trace_inheritance(logger, db, action, obj, policy):
        """Function that fills or complete the "inheritance" field of a mongo db node.
    
        The "inheritance" field must include the neccessary information about the inheritance of policies
        in that node. That information includes all the intermediate nodes (OUs and groups) and policies
    Severity: Minor
    Found in gecoscc/utils.py - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

    def set_inherited_field(logger, inheritanceTree, policy_id, false_node_list, priority_node_id):
        """Function that looks into the inheritanceTree and set the 'inherited' field of a policy to false
           if a node is in the "false_node_list" or to true if the node is the "priority_node_id"
    
        Args:
    Severity: Minor
    Found in gecoscc/utils.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function auditlog has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def auditlog(request, action=None):
        ''' Tracking user temporal information 
        
        Args:
            request(object): Pyramid request 
    Severity: Minor
    Found in gecoscc/utils.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function recalculate_policies_for_computers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def recalculate_policies_for_computers(logger, db, srcobj, computers):
        """Recalculate the policies of the object in the inheritance tree of
        the computers list.
    
        Args:
    Severity: Minor
    Found in gecoscc/utils.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function visibility_group has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def visibility_group(db, obj):
        groups = obj['memberof']
        visible_groups = []
        hide_groups = []
        ou_id = obj['path'].split(',')[-1]
    Severity: Minor
    Found in gecoscc/utils.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function get_priority_node has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_priority_node(db, nodes_list):
        """Function that the object with the top priority of the list.
    
        Args:
            db (object): Mongo DB access object.    
    Severity: Minor
    Found in gecoscc/utils.py - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function apply_policies_to_user has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def apply_policies_to_user(nodes_collection, user, auth_user, api=None,
    Severity: Major
    Found in gecoscc/utils.py - About 1 hr to fix

      Function update_data_ou has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def update_data_ou(nodes_collection, obj, policy, api, auth_user):
          members_path = obj['path'] + ',' + text_type(obj['_id'])
          members = nodes_collection.find({'path': members_path})
      
          for member in members:
      Severity: Minor
      Found in gecoscc/utils.py - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function register_node has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def register_node(api, node_id, ou, collection_nodes):
          from gecoscc.models import Computer
      
          ret = False
          node = ChefNode(node_id, api)
      Severity: Minor
      Found in gecoscc/utils.py - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function apply_policies_to_computer has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None,
      Severity: Major
      Found in gecoscc/utils.py - About 1 hr to fix

        Function apply_policies_to_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def apply_policies_to_user(nodes_collection, user, auth_user, api=None,
                                   computers=None, cookbook=None,
                                   initialize=False, use_celery=True,
                                   policies_collection=None,
                                   ous_already_visited=[],
        Severity: Minor
        Found in gecoscc/utils.py - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function recalc_node_policies has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def recalc_node_policies(nodes_collection, jobs_collection, computer, auth_user,
        Severity: Major
        Found in gecoscc/utils.py - About 1 hr to fix

          Function add_group_to_inheritance_tree has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def add_group_to_inheritance_tree(logger, db, group, inheritanceTree):
              """Function that adds a group to the inheritance tree of an object.
          
              Args:
                  logger (object): Logger.
          Severity: Minor
          Found in gecoscc/utils.py - About 1 hr to fix

            Function apply_policies_to_emitter_object has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api=None, initialize=False, use_celery=True, policies_collection=None):
            Severity: Major
            Found in gecoscc/utils.py - About 1 hr to fix

              Function apply_policies_to_computer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None,
                      cookbook=None, initialize=False, use_celery=True,
                      policies_collection=None,
                      calculate_inheritance=True,
                      validator=None):
              Severity: Minor
              Found in gecoscc/utils.py - About 55 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function recalculate_inherited_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def recalculate_inherited_field(logger, db, obj_id):
                  """Function that recalculate the "inheritance" field of a node.
              
                  Args:
                      logger (object): Logger.
              Severity: Minor
              Found in gecoscc/utils.py - About 55 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function apply_policies_to_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                  '''
                  Checks if a group is within the scope of the objects that is related and then update policies
                  '''
                  from gecoscc.tasks import object_changed, object_created
              Severity: Minor
              Found in gecoscc/utils.py - About 55 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function get_inheritance_tree_node_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_inheritance_tree_node_list(inheritanceTree, policy_id):
                  """Function that retuns a list with all the IDs of all nodes in an inheritance Tree with the policy specified.
              
                  Args:
                      inheritanceTree (object): Tree of inheritance objects
              Severity: Minor
              Found in gecoscc/utils.py - About 55 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function apply_policies_to_storage has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def apply_policies_to_storage(nodes_collection, storage, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
              Severity: Major
              Found in gecoscc/utils.py - About 50 mins to fix

                Function apply_policies_to_ou has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def apply_policies_to_ou(nodes_collection, ou, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                Severity: Major
                Found in gecoscc/utils.py - About 50 mins to fix

                  Function apply_policies_to_group has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                  Severity: Major
                  Found in gecoscc/utils.py - About 50 mins to fix

                    Function apply_change_in_inheritance has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def apply_change_in_inheritance(logger, db, action, obj, policy, node, inheritanceTree):
                    Severity: Major
                    Found in gecoscc/utils.py - About 50 mins to fix

                      Function apply_policies_to_printer has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                      Severity: Major
                      Found in gecoscc/utils.py - About 50 mins to fix

                        Function apply_policies_to_repository has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def apply_policies_to_repository(nodes_collection, repository, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                        Severity: Major
                        Found in gecoscc/utils.py - About 50 mins to fix

                          Function recalculate_inheritance_for_node has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def recalculate_inheritance_for_node(logger, db, action, obj, policy, node):
                          Severity: Minor
                          Found in gecoscc/utils.py - About 45 mins to fix

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

                            def update_data_computer(nodes_collection, obj, policy, api, auth_user):
                                from gecoscc.tasks import object_created
                                if policy and policy['slug'] != 'storage_can_view':
                                    if isinstance(policy, list):
                                        policy_field_name = []
                            Severity: Minor
                            Found in gecoscc/utils.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 not ou_id:
                                                    # Ignore empty string
                                                    continue
                                                    
                                                # Get ou from mongoDB
                            Severity: Major
                            Found in gecoscc/utils.py - About 45 mins to fix

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

                              def recalc_node_policies(nodes_collection, jobs_collection, computer, auth_user,
                                                       cookbook_name, api=None, cookbook=None,
                                                       validator=None,
                                                       initialize=True, use_celery=False):
                                  job_errors = get_job_errors_from_computer(jobs_collection, computer)
                              Severity: Minor
                              Found in gecoscc/utils.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 not ou:
                                                      logger.error("utils.py ::: calculate_initial_inheritance_for_node - OU not found %s" % str(ou_id))
                                                      return False
                                                      
                                                  else:
                              Severity: Major
                              Found in gecoscc/utils.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if previousOU['_id'] != group_ou_id:
                                                        # Get ou from mongoDB
                                                        ou = db.nodes.find_one({'_id': ObjectId(group_ou_id)})
                                                        if not ou:
                                                            logger.error("utils.py ::: calculate_initial_inheritance_for_node - OU not found %s" % str(group_ou_id))
                                Severity: Major
                                Found in gecoscc/utils.py - About 45 mins to fix

                                  Function merge_lists has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  def merge_lists(collection, obj, old_obj, attribute, remote_attribute, keyname='_id'):
                                  Severity: Minor
                                  Found in gecoscc/utils.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        for result in _nested_lookup(key, d):
                                                            yield result
                                    
                                    # ------------------------------------------------------------------------------------------------------
                                    def order_groups_by_depth(db, groups_ids):
                                    Severity: Major
                                    Found in gecoscc/utils.py - About 45 mins to fix

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

                                      def update_computers_of_user(db, user, api):
                                          from gecoscc.api.chef_status import USERS_OHAI
                                      
                                          logger.debug("utils ::: update_computers_of_user - user = %s" % str(user))
                                          nodes = db.nodes.find({'path': {'$regex': '.*' + user['path'] +'.*'}, 'type':'computer'})
                                      Severity: Minor
                                      Found in gecoscc/utils.py - About 45 mins to fix

                                      Cognitive Complexity

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

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

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

                                      Further reading

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          for mgmt in list(cookbook.keys()):
                                                              if mgmt == USER_MGMT:
                                                                  continue
                                                              cookbook.pop(mgmt)
                                                  save_node_and_free(node)
                                      Severity: Major
                                      Found in gecoscc/utils.py - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                            if not ou:
                                                                logger.error("utils.py ::: move_in_inheritance - OU not found %s" % str(ou_id))
                                                                return False
                                                                
                                                            else:
                                        Severity: Major
                                        Found in gecoscc/utils.py - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                              for policy in policy_fields:
                                                                  try:
                                                                      user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name + '.' + USER_MGMT, policy))
                                                                      users = user_mgmt.get('users')
                                                                      if not users:
                                          Severity: Major
                                          Found in gecoscc/utils.py - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                    for policy in user_mgmt:
                                                                        try:
                                                                            users = user_mgmt.get(policy).get('users')
                                                                            if not users:
                                                                                continue
                                            Severity: Major
                                            Found in gecoscc/utils.py - About 45 mins to fix

                                              Function create_chef_admin_user has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                              def create_chef_admin_user(api, settings, usrname, password=None, email='nobody@nobody.es'):
                                              Severity: Minor
                                              Found in gecoscc/utils.py - About 35 mins to fix

                                                Function set_inherited_field has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                def set_inherited_field(logger, inheritanceTree, policy_id, false_node_list, priority_node_id):
                                                Severity: Minor
                                                Found in gecoscc/utils.py - About 35 mins to fix

                                                  Function update_data_computer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                  Open

                                                  def update_data_computer(nodes_collection, obj, policy, api, auth_user):
                                                  Severity: Minor
                                                  Found in gecoscc/utils.py - About 35 mins to fix

                                                    Function update_data_user has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                    def update_data_user(nodes_collection, obj, policy, api, auth_user):
                                                    Severity: Minor
                                                    Found in gecoscc/utils.py - About 35 mins to fix

                                                      Function update_data_ou has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                      def update_data_ou(nodes_collection, obj, policy, api, auth_user):
                                                      Severity: Minor
                                                      Found in gecoscc/utils.py - About 35 mins to fix

                                                        Function get_items_ou_children has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                        def get_items_ou_children(ou_id, collection_nodes, objtype=None, filters=None, next_level=True):
                                                        Severity: Minor
                                                        Found in gecoscc/utils.py - About 35 mins to fix

                                                          Function _get_chef_api has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                          def _get_chef_api(chef_url, username, chef_pem, chef_ssl_verify, chef_version = '11.0.0'):
                                                          Severity: Minor
                                                          Found in gecoscc/utils.py - About 35 mins to fix

                                                            Function update_data_group has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                            def update_data_group(nodes_collection, obj, policy, api, auth_user):
                                                            Severity: Minor
                                                            Found in gecoscc/utils.py - About 35 mins to fix

                                                              Function trace_inheritance has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                              def trace_inheritance(logger, db, action, obj, policy):
                                                              Severity: Minor
                                                              Found in gecoscc/utils.py - About 35 mins to fix

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

                                                                def dict_merge(a, b):
                                                                    '''recursively merges dict's. not just simple a['key'] = b['key'], if
                                                                    both a and b have a key who's value is a dict then dict_merge is called
                                                                    on both values and the result stored in the returned dictionary.'''
                                                                    if not isinstance(b, dict):
                                                                Severity: Minor
                                                                Found in gecoscc/utils.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 exist_node_in_inheritance_tree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                def exist_node_in_inheritance_tree(node, inheritanceTree):
                                                                    """Function that checks if a node exists in the inheritance tree of another node.
                                                                
                                                                    Args:
                                                                        node (object): Node (OU, group, computer or user) to find.
                                                                Severity: Minor
                                                                Found in gecoscc/utils.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 _is_node_busy_and_reserve_it has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                def _is_node_busy_and_reserve_it(node_id, api, controller_requestor='gcc'):
                                                                    '''
                                                                    Check if the node is busy, else try to get it and write in control and expiration date in the field USE_NODE.
                                                                    '''
                                                                    settings = get_current_registry().settings
                                                                Severity: Minor
                                                                Found in gecoscc/utils.py - About 35 mins to fix

                                                                Cognitive Complexity

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

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

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

                                                                Further reading

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                return False             
                                                                Severity: Major
                                                                Found in gecoscc/utils.py - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return (True, 'success')
                                                                  Severity: Major
                                                                  Found in gecoscc/utils.py - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

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

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

                                                                      def get_computer_of_user(collection_nodes, user, related_computers=None):
                                                                          if related_computers is None:
                                                                              related_computers = []
                                                                          user_computers = collection_nodes.find({'_id': {'$in': user['computers']}})
                                                                          for computer in user_computers:
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py - About 25 mins to fix

                                                                      Cognitive Complexity

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

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

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

                                                                      Further reading

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

                                                                      def getURLComponents(url):
                                                                          components = {}
                                                                      
                                                                          url_re = r"(?P<protocol>(http[s]?|ftp|mongodb))://((?P<user>[^:@]+)(:(?P<password>[^@]+))?@)?(?P<host_name>[^:/]+)(:(?P<port>[0-9]+))?(?P<path>[a-zA-Z0-9\/]+)?"
                                                                          m = re.match(url_re, url)
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.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

                                                                          try:
                                                                      
                                                                              settings = get_current_registry().settings
                                                                      
                                                                              if is_cli_request():
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 day to fix
                                                                      gecoscc/utils.py on lines 2661..2679

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

                                                                      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:
                                                                       
                                                                              settings = get_current_registry().settings
                                                                      
                                                                              if is_cli_request():
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 day to fix
                                                                      gecoscc/utils.py on lines 2702..2720

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

                                                                      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 obj_related['type'] in RESOURCES_RECEPTOR_TYPES:
                                                                                      try:
                                                                                          func = globals()['update_data_%s' % obj_related['type']]
                                                                                      except KeyError:
                                                                                          raise NotImplementedError
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 7 hrs to fix
                                                                      gecoscc/utils.py on lines 814..824

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

                                                                      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 member in members:
                                                                              if member['type'] in RESOURCES_RECEPTOR_TYPES:
                                                                                  try:
                                                                                      func = globals()['update_data_%s' % member['type']]
                                                                                  except KeyError:
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 7 hrs to fix
                                                                      gecoscc/utils.py on lines 722..731

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

                                                                      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 policy_id in srcobj['policies']:
                                                                                  policydata = db.policies.find_one({'_id': ObjectId(policy_id)})
                                                                                  if not policydata:
                                                                                      logger.error("recalculate_policies_for_computers - Policy not found %s" % str(policy_id))
                                                                                      return False             
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 4 hrs to fix
                                                                      gecoscc/utils.py on lines 1710..1716

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

                                                                      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 policy_id in newnode['policies']:
                                                                                  policydata = db.policies.find_one({'_id': ObjectId(policy_id)})
                                                                                  if not policydata:
                                                                                      logger.error("move_in_inheritance_and_recalculate_policies - Policy not found %s" % str(policy_id))
                                                                                      return False             
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 4 hrs to fix
                                                                      gecoscc/utils.py on lines 1646..1652

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

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

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

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

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

                                                                      Refactorings

                                                                      Further Reading

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

                                                                      def get_object_related_list(collection, obj):
                                                                          '''
                                                                          Get the objects related list to an object
                                                                          '''
                                                                          policy_id = text_type(get_policy_emiter_id(collection, obj))
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 2 hrs to fix
                                                                      gecoscc/utils.py on lines 91..98

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

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

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

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

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

                                                                      Refactorings

                                                                      Further Reading

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

                                                                      def get_object_related_list_count(collection, obj):
                                                                          '''
                                                                          Get the objects count of the object related list to an object
                                                                          '''
                                                                          policy_id = text_type(get_policy_emiter_id(collection, obj))
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 2 hrs to fix
                                                                      gecoscc/utils.py on lines 84..89

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

                                                                      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 'policies' in obj:
                                                                                      for policy_id in obj['policies'].keys():
                                                                                          policy = db.policies.find_one({"_id": ObjectId(policy_id)})
                                                                                          recalculate_inheritance_for_node(logger, db, 'changed', obj, policy, member)            
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 2 hrs to fix
                                                                      gecoscc/utils.py on lines 1749..1752

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

                                                                      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 'policies' in group:
                                                                                      for policy_id in group['policies'].keys():
                                                                                          policy = db.policies.find_one({"_id": ObjectId(policy_id)})
                                                                                          recalculate_inheritance_for_node(logger, db, 'changed', group, policy, obj)            
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 2 hrs to fix
                                                                      gecoscc/utils.py on lines 1776..1779

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

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

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

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

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

                                                                      Refactorings

                                                                      Further Reading

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

                                                                          try:
                                                                      
                                                                              settings = get_current_registry().settings
                                                                      
                                                                              if is_cli_request():
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 2 hrs to fix
                                                                      gecoscc/utils.py on lines 2702..2729

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

                                                                      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

                                                                                      logger.debug("utils.py ::: apply_change_in_inheritance - Adding policy %s to node %s inherited by %s" % (str(policy['_id']), str(obj['_id']), str(node['_id'])))
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 2103..2103
                                                                      gecoscc/utils.py on lines 2114..2124

                                                                      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

                                                                                      logger.debug("utils.py ::: apply_change_in_inheritance - Removing policy %s to node %s inherited by %s" % (str(policy['_id']), str(obj['_id']), str(node['_id'])))
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 2116..2116
                                                                      gecoscc/utils.py on lines 2114..2124

                                                                      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 not existed:
                                                                                      # Add the policy
                                                                                      logger.debug("utils.py ::: apply_change_in_inheritance - Adding policy %s to node %s inherited by %s" % (str(policy['_id']), str(obj['_id']), str(node['_id'])))
                                                                                      this_node['policies'][policy_id] = {}
                                                                                      this_node['policies'][policy_id]['name'] = policy['name']
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 2103..2103
                                                                      gecoscc/utils.py on lines 2116..2116

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

                                                                          for ou in ous:
                                                                              if ou.get('policies', {}):
                                                                                  object_changed(auth_user, 'ou', ou, {}, computers=[computer],
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 626..628

                                                                      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 priority_node is None:
                                                                              # Check if there is an group in the list
                                                                              groups = order_groups_by_depth(db, nodes_list)
                                                                              if len(groups) > 0:
                                                                                  priority_node = groups[0]
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 1274..1278

                                                                      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 priority_node is None:
                                                                              # Check if there is an OU in the list
                                                                              ous = order_ou_by_depth(db, nodes_list)
                                                                              if len(ous) > 0:
                                                                                  priority_node = ous[0]
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 1268..1272

                                                                      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

                                                                          for group in groups:
                                                                              if group.get('policies', {}):
                                                                                  object_changed(auth_user, 'group', group, {}, computers=[computer],
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 618..620

                                                                      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

                                                                          for group_id in adds:
                                                                      
                                                                              # Add newmember to new group
                                                                              collection.update_many({
                                                                                  keyname: group_id
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 112..117

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

                                                                      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 group_id in removes:
                                                                              collection.update_many({
                                                                                  keyname: group_id
                                                                              }, {
                                                                                  '$pull': {
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 1 other location - About 1 hr to fix
                                                                      gecoscc/utils.py on lines 121..128

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

                                                                      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

                                                                          nodes_related_with_obj_count = nodes_collection.count_documents(
                                                                              {"policies.%s.object_related_list" % policy_id: {
                                                                                  '$in': [text_type(obj['_id'])]}})
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 1 other location - About 55 mins to fix
                                                                      gecoscc/utils.py on lines 706..706

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

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

                                                                                      logger.debug("utils.py ::: add_group_to_inheritance_tree - Move %s from %s to %s"%(other_node['name'], base_ou['name'], base_node['name']))
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 4 other locations - About 55 mins to fix
                                                                      gecoscc/commands/check_node_policies.py on lines 508..509
                                                                      gecoscc/commands/check_node_policies.py on lines 512..514
                                                                      gecoscc/commands/check_node_policies.py on lines 518..521
                                                                      gecoscc/commands/check_node_policies.py on lines 719..721

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

                                                                      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

                                                                          nodes_related_with_obj = nodes_collection.find({"policies.%s.object_related_list" % policy_id: {'$in': [text_type(obj['_id'])]}})
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 1 other location - About 55 mins to fix
                                                                      gecoscc/utils.py on lines 699..701

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

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

                                                                          db.nodes.update_one({'_id': obj['_id']}, {'$set':{'inheritance': obj['inheritance']}})
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 5 other locations - About 50 mins to fix
                                                                      gecoscc/api/register_computer.py on lines 98..99
                                                                      gecoscc/utils.py on lines 1758..1758
                                                                      gecoscc/utils.py on lines 1782..1782
                                                                      gecoscc/utils.py on lines 2318..2321
                                                                      gecoscc/utils.py on lines 2405..2405

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

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

                                                                          if (not '_id' in node) or (not 'name' in node):
                                                                              raise ValueError('node is not a node')      
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                              db.nodes.update_one({'_id': obj['_id']}, {'$set':{'inheritance': obj['inheritance']}})
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 5 other locations - About 50 mins to fix
                                                                      gecoscc/api/register_computer.py on lines 98..99
                                                                      gecoscc/utils.py on lines 1701..1701
                                                                      gecoscc/utils.py on lines 1782..1782
                                                                      gecoscc/utils.py on lines 2318..2321
                                                                      gecoscc/utils.py on lines 2405..2405

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

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

                                                                                  db.nodes.update_one({'_id': member['_id']}, {'$set':{'inheritance': member['inheritance']}})
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 5 other locations - About 50 mins to fix
                                                                      gecoscc/api/register_computer.py on lines 98..99
                                                                      gecoscc/utils.py on lines 1701..1701
                                                                      gecoscc/utils.py on lines 1758..1758
                                                                      gecoscc/utils.py on lines 2318..2321
                                                                      gecoscc/utils.py on lines 2405..2405

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

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

                                                                          if (not '_id' in inheritanceTree) or (not 'name' in inheritanceTree):
                                                                              raise ValueError('inheritanceTree is not a node')           
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in node) or (not 'name' in node):
                                                                              raise ValueError('node is not a node')          
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in node) or (not 'name' in node):
                                                                              raise ValueError('node is not a node')           
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in obj) or (not 'name' in obj):
                                                                              raise ValueError('obj is not a node')           
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in obj) or (not 'name' in obj):
                                                                              raise ValueError('obj is not a node')  
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in policy) or (not 'targets' in policy):
                                                                              raise ValueError('policy is not a policy')          
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in obj) or (not 'name' in obj):
                                                                              raise ValueError('obj is not a node')          
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                              db.nodes.update_one({'_id': node['_id']}, {'$set':{'inheritance': node['inheritance']}})
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 5 other locations - About 50 mins to fix
                                                                      gecoscc/api/register_computer.py on lines 98..99
                                                                      gecoscc/utils.py on lines 1701..1701
                                                                      gecoscc/utils.py on lines 1758..1758
                                                                      gecoscc/utils.py on lines 1782..1782
                                                                      gecoscc/utils.py on lines 2318..2321

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

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

                                                                          if inherited_updated:
                                                                              # Update node in mongo db to save the 'inherited' field
                                                                              db.nodes.update_one({'_id': obj['_id']},
                                                                                                  {'$set':{'inheritance': obj['inheritance']}})
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 5 other locations - About 50 mins to fix
                                                                      gecoscc/api/register_computer.py on lines 98..99
                                                                      gecoscc/utils.py on lines 1701..1701
                                                                      gecoscc/utils.py on lines 1758..1758
                                                                      gecoscc/utils.py on lines 1782..1782
                                                                      gecoscc/utils.py on lines 2405..2405

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

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

                                                                          if (not '_id' in policy) or (not 'targets' in policy):
                                                                              raise ValueError('policy is not a policy')          
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448
                                                                      gecoscc/utils.py on lines 2453..2454

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

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

                                                                          if (not '_id' in policy) or (not 'targets' in policy):
                                                                              raise ValueError('policy is not a policy')  
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 9 other locations - About 50 mins to fix
                                                                      gecoscc/utils.py on lines 2060..2061
                                                                      gecoscc/utils.py on lines 2066..2067
                                                                      gecoscc/utils.py on lines 2072..2073
                                                                      gecoscc/utils.py on lines 2078..2079
                                                                      gecoscc/utils.py on lines 2160..2161
                                                                      gecoscc/utils.py on lines 2359..2360
                                                                      gecoscc/utils.py on lines 2365..2366
                                                                      gecoscc/utils.py on lines 2371..2372
                                                                      gecoscc/utils.py on lines 2447..2448

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

                                                                      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 len(computers) > 0:
                                                                              priority_node = str(computers[0]['_id'])
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 1 other location - About 45 mins to fix
                                                                      gecoscc/utils.py on lines 1265..1266

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

                                                                      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 len(users) > 0:
                                                                                  priority_node = str(users[0]['_id'])
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 1 other location - About 45 mins to fix
                                                                      gecoscc/utils.py on lines 1259..1260

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

                                                                      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

                                                                      def apply_policies_to_storage(nodes_collection, storage, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                                                                          '''
                                                                          Checks if a storage is within the scope of the objects that is related and then update policies
                                                                          '''
                                                                          apply_policies_to_emitter_object(nodes_collection, storage, auth_user, 'storage_can_view', api, initialize, use_celery, policies_collection)
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 40 mins to fix
                                                                      gecoscc/utils.py on lines 865..869
                                                                      gecoscc/utils.py on lines 872..876

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

                                                                      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

                                                                      def apply_policies_to_repository(nodes_collection, repository, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                                                                          '''
                                                                          Checks if a repository is within the scope of the objects that is related and then update policies
                                                                          '''
                                                                          apply_policies_to_emitter_object(nodes_collection, repository, auth_user, 'repository_can_view', api, initialize, use_celery, policies_collection)
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 40 mins to fix
                                                                      gecoscc/utils.py on lines 865..869
                                                                      gecoscc/utils.py on lines 879..883

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

                                                                      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

                                                                      def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None):
                                                                          '''
                                                                          Checks if a printer is within the scope of the objects that is related and then update policies
                                                                          '''
                                                                          apply_policies_to_emitter_object(nodes_collection, printer, auth_user, 'printer_can_view', api, initialize, use_celery, policies_collection)
                                                                      Severity: Major
                                                                      Found in gecoscc/utils.py and 2 other locations - About 40 mins to fix
                                                                      gecoscc/utils.py on lines 872..876
                                                                      gecoscc/utils.py on lines 879..883

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

                                                                      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

                                                                          ous.sort(key=lambda x: x['path'].count(','), reverse=True)
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 2 other locations - About 30 mins to fix
                                                                      gecoscc/utils.py on lines 1201..1201
                                                                      gecoscc/utils.py on lines 2220..2220

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

                                                                      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

                                                                                      groups.sort(key=lambda x: x['path'].count(','), reverse=False)
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 2 other locations - About 30 mins to fix
                                                                      gecoscc/utils.py on lines 1201..1201
                                                                      gecoscc/utils.py on lines 1229..1229

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

                                                                      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

                                                                          groups.sort(key=lambda x: x['path'].count(','), reverse=True)
                                                                      Severity: Minor
                                                                      Found in gecoscc/utils.py and 2 other locations - About 30 mins to fix
                                                                      gecoscc/utils.py on lines 1229..1229
                                                                      gecoscc/utils.py on lines 2220..2220

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

                                                                      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