18F/State-TalentMAP-API

View on GitHub

Showing 40 of 40 total issues

File synchronization_helpers.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'''
This file contains a variety of helper functions for data synchronization
'''
 
from requests import Session
Severity: Minor
Found in talentmap_api/integrations/synchronization_helpers.py - About 6 hrs to fix

    Function synchronize has a Cognitive Complexity of 42 (exceeds 7 allowed). Consider refactoring.
    Open

    def synchronize(self, soap_function="IPMSDataWebService", test=False):
    '''
    Runs the SynchronizationJob
     
    Args:
    Severity: Minor
    Found in talentmap_api/integrations/models.py - About 6 hrs to fix

    Function mode_cycle_positions has a Cognitive Complexity of 33 (exceeds 7 allowed). Consider refactoring.
    Open

    def mode_cycle_positions(last_updated_date=None):
    # Set the appropriate use_last_updated string
    use_last_updated_string = ""
    if last_updated_date is not None:
    use_last_updated_string = f"<LAST_DATE_UPDATED>{last_updated_date}</LAST_DATE_UPDATED>"
    Severity: Minor
    Found in talentmap_api/integrations/synchronization_helpers.py - About 4 hrs to fix

    File models.py has 356 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import itertools
     
    from django.db.models import OuterRef, Subquery
    from django.db import models
    from djchoices import DjangoChoices, ChoiceItem
    Severity: Minor
    Found in talentmap_api/position/models.py - About 4 hrs to fix

      File settings.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Django settings for talentmap_api project.
       
      Generated by 'django-admin startproject' using Django 1.11.2.
       
       
      Severity: Minor
      Found in talentmap_api/settings.py - About 4 hrs to fix

        File common_helpers.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import datetime
         
        from pydoc import locate
         
        from dateutil.relativedelta import relativedelta
        Severity: Minor
        Found in talentmap_api/common/common_helpers.py - About 3 hrs to fix

          Function create_models_from_csv has a Cognitive Complexity of 26 (exceeds 7 allowed). Consider refactoring.
          Open

          def create_models_from_csv(self, csv_filepath):
          '''
          Loads data from an CSV file into a model, using a defined mapping of fields
          to CSV column titles.
           
           
          Severity: Minor
          Found in talentmap_api/common/xml_helpers.py - About 3 hrs to fix

          Function default_xml_action has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
          Open

          def default_xml_action(self, tag, new_instances, updated_instances):
          '''
          Returns the instance and a boolean indicating if the instance was "updated" or not
          '''
          instance = self.model()
          Severity: Minor
          Found in talentmap_api/common/xml_helpers.py - About 2 hrs to fix

          Function assignment_pre_save has a Cognitive Complexity of 22 (exceeds 7 allowed). Consider refactoring.
          Open

          def assignment_pre_save(sender, instance, **kwargs):
          '''
          This listener performs operations during the pre-save cylce of the assignment.
          '''
           
           
          Severity: Minor
          Found in talentmap_api/position/models.py - About 2 hrs to fix

          File models.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
           
          from django.utils import timezone
          from django.db.models import Q, Value, Case, When, BooleanField
          from django.db import models
          Severity: Minor
          Found in talentmap_api/bidding/models.py - About 2 hrs to fix

            Function prefetch_model has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

            def prefetch_model(cls, model, queryset, prefix="", parent_method=None, visited=None):
            '''
            This method sets up prefetch and selected related statements when applicable
            for foreign key relationships.
             
             
            Severity: Minor
            Found in talentmap_api/common/serializers.py - About 2 hrs to fix

            Function update_relationships has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

            def update_relationships(self):
            '''
            Update the organization relationships, using the codes stored in the _parent fields.
            '''
            if self._parent_bureau_code:
            Severity: Minor
            Found in talentmap_api/organization/models.py - About 2 hrs to fix

            Function __init__ has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
            Open

            def __init__(self, *args, **kwargs):
            override_fields = kwargs.pop("override_fields", [])
            override_exclude = kwargs.pop("override_exclude", [])
             
            # Initializer our parent serializer
            Severity: Minor
            Found in talentmap_api/common/serializers.py - About 2 hrs to fix

            File xml_helpers.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            '''
            This file contains helpers for loading data into the database from XML files
            '''
             
            import defusedxml.lxml as ET
            Severity: Minor
            Found in talentmap_api/common/xml_helpers.py - About 2 hrs to fix

              Function bid_status_changed has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
              Open

              def bid_status_changed(sender, instance, **kwargs):
              notification_bodies = instance.generate_status_messages()
               
              # If our instance has an id, we're performing an update (and not a create)
              if instance.id:
              Severity: Minor
              Found in talentmap_api/bidding/models.py - About 1 hr to fix

              Function update_relationships has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
              Open

              def update_relationships(self):
              '''
              Update the position relationships
              '''
              # Update language requirements
              Severity: Minor
              Found in talentmap_api/position/models.py - About 1 hr to fix

              Function create_models_from_xml has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
              Open

              def create_models_from_xml(self, xml, raw_string=False):
              '''
              Loads data from an XML file into a model, using a defined mapping of fields
              to XML tags.
               
               
              Severity: Minor
              Found in talentmap_api/common/xml_helpers.py - About 1 hr to fix

              Function parse_child_overrides has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
              Open

              def parse_child_overrides(cls, override_fields, override_exclude, name, nested, child_kwargs):
              '''
              This method populates a dictionary object with appropriate cascaded child serializers
               
              Args:
              Severity: Minor
              Found in talentmap_api/common/serializers.py - About 1 hr to fix

              Function get_soap_client has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
              Open

              def get_soap_client(cert=None, soap_function="", test=False):
              '''
              Creates a properly initialized SOAP client, with unit testing support
               
              Args:
              Severity: Minor
              Found in talentmap_api/integrations/synchronization_helpers.py - About 1 hr to fix

              Function validate_filters_exist has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
              Open

              def validate_filters_exist(filter_list, filter_class):
              for filter in filter_list.keys():
              '''
              The filter class (a subclass of FilterSet) passed into this function has knowledge of all
              implicit and declared filters. Declared filters are those explicity instantiated (typically
              Severity: Minor
              Found in talentmap_api/common/common_helpers.py - About 55 mins to fix
              Severity
              Category
              Status
              Source
              Language