MetaPhase-Consulting/State-TalentMAP-API

View on GitHub

Showing 99 of 885 total issues

Function get_log has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
Open

def get_log(log_name, size=1000):
    lines = ""
    file_name = f"{log_dir}{log_name}"
    if os.path.exists(f"{file_name}"):
        try:
Severity: Minor
Found in talentmap_api/log_viewer/services.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 send_count_request has a Cognitive Complexity of 9 (exceeds 7 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):
    '''
    Gets the total number of items for a filterset
    '''
    args = {}
Severity: Minor
Found in talentmap_api/fsbid/services/common.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 "Invalid date"
Severity: Major
Found in talentmap_api/common/common_helpers.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return Bid.Status.draft
    Severity: Major
    Found in talentmap_api/fsbid/services/bid.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return Response(status=status.HTTP_204_NO_CONTENT)
      Severity: Major
      Found in talentmap_api/available_positions/views/available_position.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return Bid.Status.handshake_accepted
        Severity: Major
        Found in talentmap_api/fsbid/services/bid.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return Bid.Status.submitted
          Severity: Major
          Found in talentmap_api/fsbid/services/bid.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return Bid.Status.handshake_needs_registered
            Severity: Major
            Found in talentmap_api/fsbid/services/bid.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return newly_created_ai_seq_num or existing_ai_seq_num
              Severity: Major
              Found in talentmap_api/fsbid/services/agenda.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return Bid.Status.in_panel
                Severity: Major
                Found in talentmap_api/fsbid/services/bid.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return parser.parse(date + '.000Z').astimezone(datetime.timezone.utc) - datetime.timedelta(hours=utc_offset)
                  Severity: Major
                  Found in talentmap_api/common/common_helpers.py - About 30 mins to fix

                    Function update_counts_for_endpoint has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                        def update_counts_for_endpoint(endpoint=None, contains=False, jwt_token='', user=''):
                            '''
                            Update all saved searches counts whose endpoint matches the specified endpoint.
                            If the endpoint is omitted, updates all saved search counts.
                    
                    
                    Severity: Minor
                    Found in talentmap_api/user_profile/models.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 get_aih_csv has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def get_aih_csv(data, filename):
                        filename = re.sub(r'(\_)\1+', r'\1', filename.replace(',', '_').replace(' ', '_').replace("'", '_'))
                        response = HttpResponse(content_type='text/csv')
                        response['Content-Disposition'] = f"attachment; filename={filename}_{datetime.now().strftime('%Y_%m_%d_%H%M%S')}.csv"
                    
                    
                    Severity: Minor
                    Found in talentmap_api/fsbid/services/common.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 get_bidders_csv has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def get_bidders_csv(self, pk, 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 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 destroy has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                        def destroy(self, request, *args, **kwargs):
                            '''
                            Closes or deletes specified bid
                    
                            This endpoint will delete bids which are still in a draft status, but close any other status
                    Severity: Minor
                    Found in talentmap_api/bidding/views/bidlist.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 save_assignment_cycle_req_mapping has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def save_assignment_cycle_req_mapping(req, is_update=False):
                        data = req['data']
                        name = data['assignmentCycle']
                        cycle_category = data['cycleCategory']
                        cycle_status = data['cycleStatus']
                    Severity: Minor
                    Found in talentmap_api/fsbid/services/assignment_cycles.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 bidderHandshakeNotification has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def bidderHandshakeNotification(bureau_user, cp_id, perdet, jwt, is_accept=True):
                        from talentmap_api.fsbid.services.cdo import single_cdo
                    
                        action = "accepted" if is_accept else "declined"
                        message = f"Bidder has {action} your handshake for a position."
                    Severity: Minor
                    Found in talentmap_api/common/common_helpers.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 map_fsbid_template_to_tm has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def map_fsbid_template_to_tm(data, mapping):
                        mapped_items = {}
                    
                        for x in mapping.items():
                            if isinstance(x[1], dict):
                    Severity: Minor
                    Found in talentmap_api/fsbid/services/common.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 fsbid_languages_to_tmap has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
                    Open

                    def fsbid_languages_to_tmap(languages):
                        tmap_languages = []
                        empty_score = '--'
                        for x in languages:
                            if not x.get('empl_language', None) or not str(x.get('empl_language')).strip():
                    Severity: Minor
                    Found in talentmap_api/fsbid/services/client.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

                    Severity
                    Category
                    Status
                    Source
                    Language