Showing 38 of 284 total issues
File __init__.py
has 644 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Flask blueprint managing the administration side of the application"""
# TODO: Restructure blueprint files- This whole thing is an absolute mess!
# Arnold Schwarzenegger looked at this code and called it "one ugly motha*****".
File modelutils.py
has 368 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Some utility classes to help with object mapping"""
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, List, Mapping, Optional, Tuple, Type, cast
File columns.py
has 322 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Defines custom column types for flask-table"""
from enum import Enum
from typing import List, Mapping, Optional, Tuple, Any
from flask import render_template_string, url_for
Function register
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def register():
"""Renders the team registration page"""
if current_app.config["CONFIGURABLE"].registration_open:
form = registration_form.RegistrationForm()
- Read upRead up
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
Team
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Team(PyMongoModel):
"""Models a team"""
RESERVED_NAMES = [config.BEACON_TEAM_NAME] + [
config.REFERENCE_TEAM_NAME.format(i) for i in range(10)
File team.py
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Models teams of participants"""
import logging
import secrets
from enum import Enum, unique
Function activation
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def activation():
"""Activates a user invitation
When the HTTP method is GET, this assumes it is from the
invitation URL generated by the admin panel and shared with
a prospective user. When this link is opened by the user, it
- Read upRead up
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 static_cache_buster
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def static_cache_buster(endpoint, values):
if "." in endpoint and "filename" in values:
(bp_name, vf_name) = endpoint.rsplit(".", 1)
else:
(bp_name, vf_name) = (None, endpoint)
- Read upRead up
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
File rules.py
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Models the game rules
See app.models.team for more information regarding the game aspect"""
import logging
Function __init__
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function post_data
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def post_data(self, datapoint: DataPoint, _force: bool = False) -> bool:
"""This is executed whenever a team sends in some data
If this returns true, it sends an OK response to the client"""
# Prevent double-dipping on points:
- Read upRead up
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 beacon_csv
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def beacon_csv():
"""CSV beacon packet bulk-upload"""
# Check admin status:
if current_user.level != UserLevel.ADMIN:
return abort(403)
- Read upRead up
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 __init__
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function _score
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _score(self, team: Team, datapoint: DataPoint, scoring_key, force=False):
"""Scores the datapoint, storing the score in the datapoint.
Set force to True to recalculate an already-scored datapoint
THIS MAKES THE *ASS*UMPTION* THAT THE TIME WINDOW IS VALID!"""
# Make sure the point is scoreable:
- Read upRead up
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 __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function table_endpoint
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def table_endpoint(table, identifier, field):
"""Endpoint for the team/user modification API
-- Action for forms within the table of users/teams"""
# Check admin status:
if current_user.level != UserLevel.ADMIN:
- Read upRead up
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 __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__( # Default gameplay parameters:
Function register_commands
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def register_commands(app):
from cubeserver_common.models.config.rules import RegularOccurrence, Rules
from cubeserver_common.models.datapoint import DataPoint, DataClass
from cubeserver_common.models.team import Team, TeamLevel
- Read upRead up
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 login
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def login():
"""The login page
Users must be activated to be able to log in.
Logging in is only useful for admin privileges so far."""
# Make sure there is a default admin user if the database is empty:
- Read upRead up
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 admin_home
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def admin_home():
"""Renders the admin console"""
# Check admin status:
if current_user.level != UserLevel.ADMIN:
return abort(403)
- Read upRead up
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"