svthalia/concrexit

View on GitHub

Showing 601 of 702 total issues

Avoid too many return statements within this function.
Open

        return False
Severity: Major
Found in website/events/services.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return redirect("index")
Severity: Major
Found in website/sales/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return development
Severity: Major
Found in website/thaliawebsite/settings.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return testing
Severity: Major
Found in website/thaliawebsite/settings.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

        return render(request, "sales/order_payment.html", {"order": order})
Severity: Major
Found in website/sales/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return Response(status=status.HTTP_200_OK)
Severity: Major
Found in website/facedetection/api/facedetection/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

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

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

        upcoming_activity = (
            Event.objects.filter(published=True, end__gte=timezone.now())
Severity: Minor
Found in website/events/views.py and 1 other location - About 30 mins to fix
website/events/views.py on lines 242..243

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

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

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

        upcoming_activity = (
            Event.objects.filter(published=True, end__gte=timezone.now())
Severity: Minor
Found in website/events/views.py and 1 other location - About 30 mins to fix
website/events/views.py on lines 32..33

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

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

        if event_lookup_field in view.kwargs:
            obj = get_object_or_404(Event, pk=view.kwargs.get(event_lookup_field))
            return is_organiser(request.member, obj)
Severity: Minor
Found in website/events/api/v2/admin/permissions.py and 1 other location - About 30 mins to fix
website/sales/api/v2/admin/permissions.py on lines 16..18

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

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

        send_email.assert_called_once_with(
            to=[settings.BOARD_NOTIFICATION_ADDRESS],
            subject="Open registration for more than one month",
            txt_template="registrations/email/reminder_open_registration.txt",
            html_template="registrations/email/reminder_open_registration.html",
Severity: Minor
Found in website/registrations/tests/test_emails.py and 1 other location - About 30 mins to fix
website/activemembers/emails.py on lines 32..39

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

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

    send_email(
        to=[member.email],
        subject="G Suite account suspended",
        txt_template="activemembers/email/gsuite_suspend.txt",
        html_template="activemembers/email/gsuite_suspend.html",
Severity: Minor
Found in website/activemembers/emails.py and 1 other location - About 30 mins to fix
website/registrations/tests/test_emails.py on lines 245..252

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

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

        if shift_lookup_field and shift_lookup_field in view.kwargs:
            obj = get_object_or_404(Shift, pk=view.kwargs.get(shift_lookup_field))
            return is_manager(request.member, obj)
Severity: Minor
Found in website/sales/api/v2/admin/permissions.py and 1 other location - About 30 mins to fix
website/events/api/v2/admin/permissions.py on lines 15..17

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

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

Severity
Category
Status
Source
Language