SpartaHack/SpartaHack-API

View on GitHub
resources/applications.py

Summary

Maintainability
D
2 days
Test Coverage

File applications.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from flask_restful import Resource
from werkzeug.exceptions import BadRequest
from flask import request, jsonify, g
from flask import current_app as app
from datetime import datetime
Severity: Minor
Found in resources/applications.py - About 2 hrs to fix

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

    def post(self):
        """
        Create new application. Required data:
        birth_day
        birth_month
Severity: Minor
Found in resources/applications.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 put has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def put(self, application_id):
        """
        Update the application. Required data: application_id
        birth_day
        birth_month
Severity: Minor
Found in resources/applications.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 delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def delete(self, application_id):
        """
        Delete the application. Required data: application_id
        """
        user_status, calling_user = has_admin_privileges()
Severity: Minor
Found in resources/applications.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, application_id):
        """
        GET the application details based on specific application_id
        """
        # using get instead of filter and it is marginally faster than filter
Severity: Minor
Found in resources/applications.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

Avoid too many return statements within this function.
Open

                return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return (forbidden, 403, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (forbidden, 403, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (ret, 201, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (not_found, 404, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (not_found, 404, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (forbidden, 403, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (not_found, 404, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return (conflict, 409, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (internal_server_error, 500, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (forbidden, 403, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (ret, 200, headers)
Severity: Major
Found in resources/applications.py - About 30 mins to fix

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

    def get(self):
        """
        GET all the applications at a time.
        """
        user_status, calling_user = has_admin_privileges()
Severity: Minor
Found in resources/applications.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

There are no issues that match your filters.

Category
Status