Showing 46 of 104 total issues
File usersuite.py
has 539 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Blueprint for Usersuite components
"""
from collections import OrderedDict
import logging
from datetime import datetime
File forms.py
has 476 lines of code (exceeds 250 allowed). Consider refactoring. Open
import re
from datetime import date
from operator import itemgetter
from flask_babel import gettext, lazy_gettext
User
has 39 functions (exceeds 20 allowed). Consider refactoring. Open
class User(BaseUser):
user_data: UserData
def __init__(self, user_data: dict):
try:
User
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class User(BaseUser):
def __init__(self, uid):
super().__init__(uid)
self.config: SampleUserData = config[uid]
self._realname = self.config["name"]
File user.py
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import logging
from datetime import date
from pydantic import ValidationError
File test_mail.py
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
from dataclasses import dataclass, field
from unittest import TestCase
from unittest.mock import MagicMock, patch
from sipa.mail import send_contact_mail, send_complex_mail, \
File generic.py
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import os
from flask import (
render_template,
Function data
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def data(reg_state: RegisterState):
form = RegisterFinishForm()
form.member_begin_date.min = date.today()
if form.validate_on_submit():
try:
- 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 flatpages.py
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import logging
from dataclasses import dataclass, field
from functools import cached_property, lru_cache
File user.py
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import typing as t
# noinspection PyMethodMayBeStatic
from abc import ABCMeta, abstractmethod
PycroftApi
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class PycroftApi:
def __init__(self, endpoint: str, api_key: str):
if not endpoint.endswith("/"):
raise InvalidConfiguration("API endpoint must end with a '/'")
self._endpoint = endpoint
Function identify
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def identify(reg_state: RegisterState):
form = RegisterIdentifyForm()
form.previous_dorm.choices = [_dorm_summary('', '')] + backends.dormitories_short
suggest_skip = False
- 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 15 (exceeds 5 allowed). Consider refactoring. Open
def login():
"""Login page for users
"""
form = LoginForm()
- 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 send_mail
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def send_mail(author: str, recipient: str, subject: str, message: str,
reply_to: str = None) -> bool:
"""Send a MIME text mail
Send a mail from ``author`` to ``receipient`` with ``subject`` and
- 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 terminate_membership_confirm
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def terminate_membership_confirm():
"""
As member, cancel your membership to a given date
:return:
"""
- 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 usertraffic
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def usertraffic():
"""Show a user's traffic on a static site just as in the usersuite.
If a user is logged but the ip corresponds to another user, a hint
is flashed and the traffic of the `ip_user` is displayed.
- 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_env_and_config
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def init_env_and_config(app):
if not app.config.get("FLATPAGES_ROOT"):
app.config["FLATPAGES_ROOT"] = os.path.join(
os.path.dirname(__file__),
"../content",
- 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 evaluate_status
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_status(self, status: UserStatus):
message = None
style = None
if status.violation:
message, style = gettext('Verstoß gegen Netzordnung'), 'danger'
- 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_app
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def init_app(app, **kwargs):
"""Initialize the Flask app located in the module sipa.
This initializes the Flask app by:
* calling the internal init_app() procedures of each module
Function member_request
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def member_request(self, email: str, login: str, password: str,