Showing 284 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*****".
Similar blocks of code found in 2 locations. Consider refactoring. Open
function deleteItem(item, id) {
// TODO: Replace confirm() and alert() with a nice-looking Bootstrap modal
var confirmationMessage = `Are you certain you wish to DELETE object #${id} FOREVER?\n
This action is PERMANANT and CANNOT BE UNDONE!`;
//var comment = prompt("Please comment on this change."); // TODO: Add comment in case of deleted objects also
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 193.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
function recompute_score(item, id) {
// TODO: Replace confirm() and alert() with a nice-looking Bootstrap modal
var confirmationMessage = `Are you certain you wish to RECOMPUTE object #${id}'s score?\n
All/the datapoint(s) will be re-evaluated under the current scoring rules and multiplier.\n
All manual score increments on this object will be lost.\n
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 193.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 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
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
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 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 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 __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 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"