svthalia/concrexit

View on GitHub

Showing 601 of 702 total issues

File test_services.py has 523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django.core import mail
from django.test import TestCase, override_settings
from django.utils import timezone

from freezegun import freeze_time
Severity: Major
Found in website/registrations/tests/test_services.py - About 1 day to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class FoodEventDateFilterBackend(filters.BaseFilterBackend):
    """Allows you to filter by event start/end dates."""

    def filter_queryset(self, request, queryset, view):
        start, end = extract_date_range(request, allow_empty=True)
Severity: Major
Found in website/pizzas/api/v2/filters.py and 1 other location - About 1 day to fix
website/events/api/v2/filters.py on lines 6..35

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 128.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class EventDateFilter(filters.BaseFilterBackend):
    """Allows you to filter by event start/end dates."""

    def filter_queryset(self, request, queryset, view):
        start, end = extract_date_range(request, allow_empty=True)
Severity: Major
Found in website/events/api/v2/filters.py and 1 other location - About 1 day to fix
website/pizzas/api/v2/filters.py on lines 6..35

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 128.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        with self.subTest("Member, membership upgrade discount (last year)"):
            with freeze_time("2024-10-20"):
                # The user had a membership last year, but still should get a discount.
                self.data["length"] = Entry.MEMBERSHIP_STUDY
                self.data["membership_type"] = Membership.MEMBER
Severity: Major
Found in website/registrations/tests/test_forms.py and 1 other location - About 1 day to fix
website/registrations/tests/test_forms.py on lines 166..178

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 128.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        with self.subTest("Member, membership upgrade discount"):
            with freeze_time("2024-08-20"):
                self.data["length"] = Entry.MEMBERSHIP_STUDY
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 1 other location - About 1 day to fix
website/registrations/tests/test_forms.py on lines 180..193

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 128.

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

Further Reading

Function clean has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        super().clean()
        errors = {}
        if self.start is None:
            errors.update({"start": _("Start cannot have an empty date or time field")})
Severity: Minor
Found in website/events/models/event.py - About 7 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

File test_api.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime

from django.test import TestCase, override_settings
from django.urls import reverse
from django.utils import timezone
Severity: Minor
Found in website/events/tests/test_api.py - About 7 hrs to fix

File test_services.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from random import randint
from unittest import mock

from django.test import TestCase, override_settings
from django.utils import timezone
Severity: Minor
Found in website/moneybirdsynchronization/tests/test_services.py - About 7 hrs to fix

File test_models.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
from decimal import Decimal
from unittest.mock import PropertyMock, patch

from django.core.exceptions import ValidationError
Severity: Minor
Found in website/payments/tests/test_models.py - About 7 hrs to fix

File services.py has 475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging

from django.conf import settings
from django.contrib.admin.utils import model_ngettext
from django.contrib.contenttypes.models import ContentType
Severity: Minor
Found in website/moneybirdsynchronization/services.py - About 7 hrs to fix

File models.py has 475 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""The models defined by the registrations package."""
import string
import unicodedata
import uuid

Severity: Minor
Found in website/registrations/models.py - About 7 hrs to fix

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Benefactor, year member membership after expiry"):
            with freeze_time("2024-09-10"):
                self.data["length"] = Entry.MEMBERSHIP_YEAR
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 304..315
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Member, study membership after more than a year"):
            with freeze_time("2025-09-10"):
                # The membership discount applies up to 1 year after the user last had a membership.
                self.data["length"] = Entry.MEMBERSHIP_STUDY
                self.data["membership_type"] = Membership.MEMBER
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 304..315
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Benefactor, study membership before expiry"):
            with freeze_time("2024-08-20"):
                self.data["length"] = Entry.MEMBERSHIP_STUDY
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Benefactor, year member membership before expiry"):
            with freeze_time("2024-08-20"):
                self.data["length"] = Entry.MEMBERSHIP_YEAR
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 304..315
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Member, new year membership before expiry"):
            with freeze_time("2024-08-20"):
                self.data["length"] = Entry.MEMBERSHIP_YEAR
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 304..315
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Member, new year membership after expiry"):
            with freeze_time("2024-09-10"):
                self.data["length"] = Entry.MEMBERSHIP_YEAR
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 304..315
website/registrations/tests/test_forms.py on lines 317..328

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 112.

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

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

        with self.subTest("Benefactor, study membership after expiry"):
            with freeze_time("2024-09-10"):
                self.data["length"] = Entry.MEMBERSHIP_STUDY
                self.data["membership_type"] = Membership.MEMBER
                form = forms.RenewalForm(self.data)
Severity: Major
Found in website/registrations/tests/test_forms.py and 6 other locations - About 7 hrs to fix
website/registrations/tests/test_forms.py on lines 195..206
website/registrations/tests/test_forms.py on lines 208..219
website/registrations/tests/test_forms.py on lines 221..233
website/registrations/tests/test_forms.py on lines 278..289
website/registrations/tests/test_forms.py on lines 291..302
website/registrations/tests/test_forms.py on lines 304..315

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 112.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        with self.subTest("Dry run should not actually delete"):
            p = Payment.objects.create(
                paid_by=self.member,
                amount=1,
                created_at=timezone.now() - timezone.timedelta(days=(365 * 7) + 1),
Severity: Major
Found in website/payments/tests/test_services.py and 1 other location - About 6 hrs to fix
website/payments/tests/test_services.py on lines 232..242

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 108.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        with self.subTest("Payments that are 7 years old must be minimised"):
            p = Payment.objects.create(
                paid_by=self.member,
                amount=1,
                created_at=timezone.now() - timezone.timedelta(days=(365 * 7) + 1),
Severity: Major
Found in website/payments/tests/test_services.py and 1 other location - About 6 hrs to fix
website/payments/tests/test_services.py on lines 256..266

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 108.

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

Further Reading

Severity
Category
Status
Source
Language