svthalia/concrexit

View on GitHub

Showing 227 of 702 total issues

Function get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, request, *args, **kwargs):
        """Mark a user as present.

        Checks if the url is correct, the event has not ended yet, and the user is registered.
        """
Severity: Minor
Found in website/events/views.py - About 45 mins 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 update_event_start_reminder_users_on_registration_save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def update_event_start_reminder_users_on_registration_save(sender, instance, **kwargs):
    """Add or remove the member from the event start reminder."""
    message = getattr(instance.event, "start_reminder", None)

    if message is None or message.sent:
Severity: Minor
Found in website/pushnotifications/signals/events.py - About 45 mins 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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        try:
            if self.until and (not self.since or self.until < self.since):
                raise ValidationError(
                    {"until": _("End date can't be before start date")}
Severity: Minor
Found in website/activemembers/models.py - About 45 mins 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 pre_member_save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def pre_member_save(instance, **kwargs):
    if not settings.GSUITE_MEMBERS_AUTOSYNC:
        return

    existing_member = Member.objects.filter(pk=instance.pk).first()
Severity: Minor
Found in website/activemembers/signals.py - About 45 mins 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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __call__(self, request, *args, **kwargs):
        event = None

        if "pk" in kwargs:
            try:
Severity: Minor
Found in website/events/decorators.py - About 45 mins 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 create_or_update_contact has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def create_or_update_contact(member: Member):
    """Push a Django user/member to Moneybird."""
    if not settings.MONEYBIRD_SYNC_ENABLED:
        return None

Severity: Minor
Found in website/moneybirdsynchronization/services.py - About 45 mins 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 get_used_media has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_used_media(storage):
    """Get the filenames of all files stored in a FileField of any model."""
    media = set()

    for field in get_file_fields():
Severity: Minor
Found in website/utils/management/commands/remove_unused_media.py - About 45 mins 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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        verbosity = options.get("verbosity")

        private_storage = DefaultStorage()
        unused_private_media = get_unused_media(
Severity: Minor
Found in website/utils/management/commands/remove_unused_media.py - About 45 mins 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__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, field, request, params, model, model_admin, field_path):
Severity: Minor
Found in website/promotion/admin.py - About 45 mins to fix

Function formfield_for_foreignkey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def formfield_for_foreignkey(self, db_field, request, **kwargs):
        """Customise the formfields of event and member."""
        if db_field.name == "event":
            # allow to restrict event
            if request.GET.get("event_pk"):
Severity: Minor
Found in website/events/admin/registration.py - About 45 mins 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 execute_data_minimisation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def execute_data_minimisation(dry_run=False, members=None) -> list[Member]:
    """Clean the profiles of members/users of whom the last membership ended at least 31 days ago.

    :param dry_run: does not really remove data if True
    :param members: queryset of members to process, optional
Severity: Minor
Found in website/members/services.py - About 45 mins 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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        if self.amount == 0:
            raise ValidationError({"amount": f"Payments cannot be €{self.amount}"})
        if self.type != Payment.TPAY and self.batch is not None:
            raise ValidationError(
Severity: Minor
Found in website/payments/models.py - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                    if category["name"] not in categories:
                        categories[category["name"]] = {"items": [], **category}

Severity: Major
Found in website/thaliawebsite/templatetags/menu.py - About 45 mins to fix

Function get_context has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def get_context(self, name, value, attrs) -> dict:
        context = super().get_context(name, value, attrs)
        if self.obj:
            # Make sure to ALWAYS use committed data from the database, and never invalid data that is not saved, for example from an invalid form
            self.obj.refresh_from_db()
Severity: Minor
Found in website/payments/widgets.py - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                    if section["name"] not in sections:
                        sections[section["name"]] = {"items": [], **section}

Severity: Major
Found in website/thaliawebsite/templatetags/menu.py - About 45 mins to fix

Function setting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def setting(*, development, production, staging=_NOT_SET, testing=_NOT_SET):
    """Generate a setting depending on the DJANGO_ENV and the arguments.

    This function is meant for static settings that depend on the DJANGO_ENV. If the
    staging or testing arguments are left to their defaults, they will fall back to
Severity: Minor
Found in website/thaliawebsite/settings.py - About 45 mins 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 clean has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def clean(self):
        super().clean()
        errors = {}

        if not self.is_minimized and not (
Severity: Minor
Found in website/members/models/profile.py - About 45 mins 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 from_env has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def from_env(
Severity: Minor
Found in website/thaliawebsite/settings.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                            if not input_value.strip():
                                user_data[field_name] = None
                                self.stderr.write("Error: This field cannot be blank.")
                                continue
                            user_data[field_name] = [
Severity: Major
Found in website/members/management/commands/createmember.py - About 45 mins to fix

Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def save(
        self, force_insert=False, force_update=False, using=None, update_fields=None
    ):
        if self.order.shift.locked:
            raise ValueError("The shift this order belongs to is locked.")
Severity: Minor
Found in website/sales/models/order.py - About 45 mins 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

Severity
Category
Status
Source
Language