Showing 104 of 104 total issues

Cyclomatic complexity is too high in function reset_wifi_password. (6)
Open

@bp_usersuite.route("/reset-wifi-password", methods=['GET', 'POST'])
@login_required
def reset_wifi_password():
    """
    Reset the wifi password
Severity: Minor
Found in sipa/blueprints/usersuite.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in method test_traffic_history. (6)
Open

    def test_traffic_history(self, user):
        for day in user.traffic_history:
Severity: Minor
Found in tests/model/test_sample.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in method dispatch_request. (6)
Open

    def dispatch_request(self, filename):
        if self.login_required and not current_user.is_authenticated:
            return current_app.login_manager.unauthorized()

        if self.member_required and not current_user.is_member:
Severity: Minor
Found in sipa/blueprints/documents.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in method renders_template. (6)
Open

    @contextlib.contextmanager
    def renders_template(
        self, template: str, allow_others: bool = False
    ) -> t.Iterator[list[tuple[j.Template, t.Any]]]:
        app = self.application
Severity: Minor
Found in tests/assertions.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in method __call__. (6)
Open

    def __call__(self, form, field, message=None):
        password = field.data or ''

        if len(password) < self.min_length:
            self.raise_error(message)
Severity: Minor
Found in sipa/forms.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

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
Severity: Minor
Found in sipa/mail.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

Error: invalid syntax (<unknown>, line 154)</unknown>
Open

    if url := app.config["CONTENT_URL"]:
Severity: Minor
Found in sipa/initialization.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 16)</unknown>
Open

        "sipa.blueprints.features.get_bustimes", mock := MagicMock()
Severity: Minor
Found in tests/blueprints/test_bp_features.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 143)</unknown>
Open

        match val:
Severity: Minor
Found in sipa/model/user.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<fstring>, line 1)</fstring>
Open

import re

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 77)</unknown>
Open

        match weekday:
Severity: Minor
Found in sipa/model/finance.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 26)</unknown>
Open

        self.style_nonces.append(n := generate_nonce())
Severity: Minor
Found in sipa/utils/csp.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 66)</unknown>
Open

    if not (r := requests.get(uri)):
Severity: Minor
Found in sipa/utils/__init__.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 20)</unknown>
Open

    if (locale_identifier := session.get("locale")) is None:
Severity: Minor
Found in sipa/babel.py by radon

We encountered an error attempting to analyze this line.

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:
    """
Severity: Minor
Found in sipa/blueprints/usersuite.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 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.
Severity: Minor
Found in sipa/blueprints/generic.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 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'
Severity: Minor
Found in sipa/model/pycroft/user.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 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",
Severity: Minor
Found in sipa/initialization.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 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
Severity: Minor
Found in sipa/initialization.py - About 1 hr to fix

    Function member_request has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def member_request(self, email: str, login: str, password: str,
    Severity: Major
    Found in sipa/model/pycroft/api.py - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language