SpartaHack/SpartaHack-API

View on GitHub
resources/users.py

Summary

Maintainability
F
3 days
Test Coverage

File users.py has 382 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 marshmallow import validate, ValidationError
Severity: Minor
Found in resources/users.py - About 5 hrs to fix

Function delete has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def delete(self, auth_id):
        """
        DELETE user request. Only Directors, Organizers and user calling the request
        """
        user_status, calling_user = has_admin_privileges()
Severity: Minor
Found in resources/users.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 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, auth_id):
        """
        GET the user details based on specific auth_id
        We are considering user and application separate entities. Previously, a user submitted the application details at the time of user account creation.
        Now, the user creates an account and then logs in to submit the application.
Severity: Minor
Found in resources/users.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 post has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self):
        try:
            data = request.get_json(force=True)
        except BadRequest:
            return (bad_request, 400, headers)
Severity: Minor
Found in resources/users.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 post has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self):
        """
        Only method needed
        """
        user_status, calling_user = has_admin_privileges()
Severity: Minor
Found in resources/users.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 post has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self):
        """
        Only method needed
        """
        user_status, calling_user = has_admin_privileges()
Severity: Minor
Found in resources/users.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 post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self):
        try:
            data = request.get_json(force=True)
        except BadRequest:
            return (bad_request, 400, headers)
Severity: Minor
Found in resources/users.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 too many return statements within this function.
Open

                return (User_Schema().dump(user), 200, headers)
Severity: Major
Found in resources/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return (forbidden, 403, headers)
Severity: Major
Found in resources/users.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/users.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/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return (User_Schema().dump(calling_user), 200, headers)
Severity: Major
Found in resources/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (gone, 410, headers)
Severity: Major
Found in resources/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return (User_Schema().dump(calling_user).data, 200, headers)
Severity: Major
Found in resources/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return(forbidden, 403, headers)
Severity: Major
Found in resources/users.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/users.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/users.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/users.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/users.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/users.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/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (User_Schema().dump(user).data, 200, headers)
Severity: Major
Found in resources/users.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/users.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/users.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/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return (forbidden, 403, headers)
Severity: Major
Found in resources/users.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/users.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/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

                    return (forbidden, 403, headers)
Severity: Major
Found in resources/users.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/users.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/users.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/users.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return ({"status": "Reset password token set at "+data["email"]}, 200, headers)
Severity: Major
Found in resources/users.py - About 30 mins to fix

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

    def post(self):
        """
        Create new user. Required data: email,ID_Token,first_name,last_name
        """
        Users = g.Base.classes.users
Severity: Minor
Found in resources/users.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self):
        """
        GET all the users at a time.
        Application_id and rsvp_id is not gonna be returned when GET is called on all the users.
        Because getting the application_id and rsvp_id makes db calls and making calls for application_id and rsvp_id on hundreds of users is costly.
Severity: Minor
Found in resources/users.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