svthalia/concrexit

View on GitHub

Showing 227 of 702 total issues

Avoid too many return statements within this function.
Open

        return self.user.get_full_name() or self.user.username
Severity: Major
Found in website/members/models/profile.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return _(
Severity: Major
Found in website/payments/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return queryset
Severity: Major
Found in website/members/admin.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return f"{self.user.first_name} '{self.nickname}' {self.user.last_name}"
Severity: Major
Found in website/members/models/profile.py - About 30 mins to fix

Function fetch_thumbnails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def fetch_thumbnails(images: list, sizes=None):
    """Prefetches thumbnails from the database or redis efficiently.

    :param images: A list of images to prefetch thumbnails for.
    :param sizes: A list of sizes to prefetch. If None, all sizes will be prefetched.
Severity: Minor
Found in website/utils/media/services.py - About 25 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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def save(self, **kwargs):
        if not self.publish_date and self.event:
            self.publish_date = self.event.start.date()
        oldstatus = None
        if self.pk:
Severity: Minor
Found in website/promotion/models.py - About 25 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_file_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_file_fields():
    """Get all FileFields of all models."""
    all_models = apps.get_models()
    fields = []
    for model in all_models:
Severity: Minor
Found in website/utils/management/commands/remove_unused_media.py - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def create(self, request, *args, **kwargs):
        if self.food_event.start > timezone.now():
            raise PermissionDenied("You cannot order food yet")
        if self.food_event.has_ended:
            raise PermissionDenied("Event has ended")
Severity: Minor
Found in website/pizzas/api/v2/views.py - About 25 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 is_organiser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def is_organiser(member, event):
    if member and member.is_authenticated:
        if member.is_superuser or member.has_perm("events.override_organiser"):
            return True

Severity: Minor
Found in website/events/services.py - About 25 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_automatic_mailinglists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_automatic_mailinglists():
    """Return mailing list names that should be generated automatically."""
    lectureyear = datetime_to_lectureyear(timezone.now())
    list_names = [
        "leden",
Severity: Minor
Found in website/mailinglists/models.py - About 25 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_absolute_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_absolute_url(self):
        try:
            return self.board.get_absolute_url()
        except self.DoesNotExist:
            try:
Severity: Minor
Found in website/activemembers/models.py - About 25 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 add_registered_member_to_food_order_reminder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def add_registered_member_to_food_order_reminder(sender, instance, **kwargs):
    """Update members on food order reminder notification."""
    if not instance.event.has_food_event:
        return

Severity: Minor
Found in website/pushnotifications/signals/pizzas.py - About 25 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_queryset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_queryset(self):
        queryset = Event.objects.filter(published=True)

        if (
            self.action == "retrieve"
Severity: Minor
Found in website/events/api/v1/viewsets/events.py - About 25 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 set_value_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def set_value_for(self, registration, value):
        if self.type == self.TEXT_FIELD:
            value_set = self.textregistrationinformation_set
        elif self.type == self.BOOLEAN_FIELD:
            value_set = self.booleanregistrationinformation_set
Severity: Minor
Found in website/events/models/registration_information_field.py - About 25 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 add_to_last_batch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_to_last_batch(self, request: HttpRequest, queryset: QuerySet) -> None:
        """Add selected TPAY payments to the last batch."""
        tpays = queryset.filter(type=Payment.TPAY)
        if len(tpays) > 0:
            batch = Batch.objects.last()
Severity: Minor
Found in website/payments/admin.py - About 25 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 data_minimisation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def data_minimisation():
    processed = members_services.execute_data_minimisation()
    for p in processed:
        logger.info(f"Removed data for {p}")

Severity: Minor
Found in website/thaliawebsite/tasks.py - About 25 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 _sync_moneybird_payments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _sync_moneybird_payments():
    """Create financial statements with all payments that haven't been synced yet.

    This creates one statement per payment type for which there are new payments.
    """
Severity: Minor
Found in website/moneybirdsynchronization/services.py - About 25 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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self, request, *args, **kwargs):
        if not (
            request.POST.keys()
            >= {"app_label", "model_name", "payable", "payable_hash", "next"}
        ):
Severity: Minor
Found in website/payments/views.py - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        processed = members_services.execute_data_minimisation(options["dry-run"])
        for p in processed:
            self.stdout.write(f"Removed data for {p}")

Severity: Minor
Found in website/thaliawebsite/management/commands/dataminimisation.py - About 25 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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self, request, *args, **kwargs):
        request.POST = request.POST.dict()
        if request.member.latest_membership.type == Membership.BENEFACTOR:
            request.POST["membership_type"] = Membership.BENEFACTOR
            request.POST["length"] = Entry.MEMBERSHIP_YEAR
Severity: Minor
Found in website/registrations/views.py - About 25 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