SCUEvals/scuevals-api

View on GitHub

Showing 7 of 26 total issues

Function auth has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

def auth(args):
    try:
        headers = jwt.get_unverified_header(args['id_token'])
    except JWTError as e:
        raise UnprocessableEntity('invalid id_token: invalid format: {}'.format(e))
Severity: Minor
Found in scuevals_api/auth/views.py - About 6 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 auth_required has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def auth_required(fn, *permissions):
    """
    Decorating a view with this ensures that the requester provided a JWT
    and that the requester has any of the permissions needed to access the view.
    """
Severity: Minor
Found in scuevals_api/auth/decorators.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_evals_json has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def get_evals_json(args, student_id=None):
    evals = Evaluation.query

    if 'professor' in args['embed']:
        evals = evals.options(subqueryload(Evaluation.professor))
Severity: Minor
Found in scuevals_api/resources/evaluations.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 scrape_majors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def scrape_majors(args):
    resp = requests.get(SCU_URL + 'academics/undergraduate-programs/')
    if not resp.status_code == 200:
        raise Exception('Non-OK status code: ' + str(resp.status_code))

Severity: Minor
Found in scraper/scraper.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 handle_request_parsing_error has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def handle_request_parsing_error(err, req, schema, status_code, headers):
Severity: Minor
Found in scuevals_api/utils.py - About 35 mins to fix

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

        def post(self, args, e_id):
    
            evaluation = get_eval(e_id)
    
            # do not allow flagging your own evaluations
    Severity: Minor
    Found in scuevals_api/resources/evaluations.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 _set_read_access has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_read_access(self, value):
            if value:
                # extend the read access until the set value
                self.read_access_until = value
    
    
    Severity: Minor
    Found in scuevals_api/models/student.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