MetaPhase-Consulting/State-TalentMAP-API

View on GitHub

Showing 98 of 887 total issues

Function get_bids_csv has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def get_bids_csv(data, filename, jwt_token):
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = f"attachment; filename={filename}_{datetime.now().strftime('%Y_%m_%d_%H%M%S')}.csv"

    writer = csv.writer(response, csv.excel)
Severity: Minor
Found in talentmap_api/fsbid/services/common.py - About 1 hr to fix

    Function perform_create has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
    Open

        def perform_create(self, serializer):
            if isinstance(self.request.data, list):
                data = self.request.data
                # Empty array
                if len(data) == 0:
    Severity: Minor
    Found in talentmap_api/available_positions/views/available_position.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 convert_agenda_employees_query has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
    Open

    def convert_agenda_employees_query(query):
        '''
        Convert TalentMAP filters into FSBid filters
        '''
    
    
    Severity: Minor
    Found in talentmap_api/fsbid/services/agenda_employees.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 fsbid_single_agenda_item_to_talentmap_single_agenda_item has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def fsbid_single_agenda_item_to_talentmap_single_agenda_item(data, ref_skills={}):
        agendaStatusAbbrev = {
            "Approved": "APR",
            "Deferred - Proposed Position": "XXX",
            "Disapproved": "DIS",
    Severity: Minor
    Found in talentmap_api/fsbid/services/agenda.py - About 1 hr to fix

      Function send_get_csv_request has 10 arguments (exceeds 5 allowed). Consider refactoring.
      Open

      def send_get_csv_request(uri, query, query_mapping_function, jwt_token, mapping_function, base_url, host=None, ad_id=None, limit=None, use_post=False):
      Severity: Major
      Found in talentmap_api/fsbid/services/common.py - About 1 hr to fix

        Function send_get_request has 10 arguments (exceeds 5 allowed). Consider refactoring.
        Open

        def send_get_request(uri, query, query_mapping_function, jwt_token, mapping_function, count_function, base_url, host=None, api_root=API_ROOT, use_post=False):
        Severity: Major
        Found in talentmap_api/fsbid/services/common.py - About 1 hr to fix

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

          def get_bids_csv(data, filename, jwt_token):
              response = HttpResponse(content_type='text/csv')
              response['Content-Disposition'] = f"attachment; filename={filename}_{datetime.now().strftime('%Y_%m_%d_%H%M%S')}.csv"
          
              writer = csv.writer(response, csv.excel)
          Severity: Minor
          Found in talentmap_api/fsbid/services/common.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_bid_status has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def get_bid_status(statusCode, handshakeCode, assignmentCreateDate, panelMeetingStatus, handshakeAllowed):
              '''
              Map the FSBid status code and handshake code to a TalentMap status
                  statusCode - W → Draft
          
          
          Severity: Minor
          Found in talentmap_api/fsbid/services/bid.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 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

          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 service_response has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def service_response(data, objStr, mapping=None):
              '''
              Returns data with additional logger and error handling depending on type
              '''
              if data is None:
          Severity: Minor
          Found in talentmap_api/common/common_helpers.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_fsbid_results has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
          Open

          def get_fsbid_results(uri, jwt_token, mapping_function, email=None, use_cache=False, api_root=API_ROOT):
              url = f"{api_root}/{uri}"
              # TODO - fix SSL issue with use_cache
              # method = session if use_cache else requests
              method = requests
          Severity: Minor
          Found in talentmap_api/fsbid/services/common.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 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

          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 send_count_request has 8 arguments (exceeds 5 allowed). Consider refactoring.
          Open

          def send_count_request(uri, query, query_mapping_function, jwt_token, host=None, api_root=API_ROOT, use_post=False, is_template=False):
          Severity: Major
          Found in talentmap_api/fsbid/services/common.py - About 50 mins to fix

            Function get_individual has 7 arguments (exceeds 5 allowed). Consider refactoring.
            Open

            def get_individual(uri, query, query_mapping_function, jwt_token, mapping_function, api_root=API_ROOT, use_post=False):
            Severity: Major
            Found in talentmap_api/fsbid/services/common.py - About 45 mins to fix

              Function bureau_exceptions_res_mapping has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
              Open

              def bureau_exceptions_res_mapping(data):
                  if data is None or (data['O_RETURN_CODE'] and data['O_RETURN_CODE'] is not 0):
                      logger.error('FSBid call for Bureau Exceptions failed.')
                      return None
                      
              Severity: Minor
              Found in talentmap_api/fsbid/services/bureau_exceptions.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 ail in existing_ails:
                                          ai_seq_num = query["aiseqnum"]
                                          delete_agenda_item_leg(ail, ai_seq_num, jwt_token)
                                  for leg in legs:
              Severity: Major
              Found in talentmap_api/fsbid/services/agenda.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if not pydash.get(agenda_item_leg, "[0].ail_seq_num"):
                                            logger.error("Error creating AIL")
                                
                                # Unpack existing AIR/AIRI
                                existing_remarks = refData.get("remarks")
                Severity: Major
                Found in talentmap_api/fsbid/services/agenda.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not pydash.get(agenda_item_remark, "[0].rmrk_seq_num"):
                                              logger.error("Error creating AIR")
                                          elif remark_inserts:
                                              for insert in remark_inserts:
                                                  agenda_item_remark_insert = create_agenda_item_remark_insert(insert, query, jwt_token)
                  Severity: Major
                  Found in talentmap_api/fsbid/services/agenda.py - About 45 mins to fix

                    Function get_available_bidders_csv has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def get_available_bidders_csv(request):
                        '''
                        Returns csv format of all users in Available Bidders list
                        '''
                        data = client_services.get_available_bidders(request.META['HTTP_JWT'], False, request.query_params, f"{request.scheme}://{request.get_host()}")
                    Severity: Minor
                    Found in talentmap_api/bureau/services/available_bidders.py - About 45 mins to fix

                    Cognitive Complexity

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

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

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

                    Further reading

                    Function sorting_values has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def sorting_values(sort, use_post=False):
                        if sort is not None:
                            results = []
                            for s in sort.split(','):
                                direction = 'asc'
                    Severity: Minor
                    Found in talentmap_api/fsbid/services/common.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

                    Severity
                    Category
                    Status
                    Source
                    Language