svthalia/concrexit

View on GitHub

Showing 227 of 702 total issues

Function send has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def send(self, **kwargs):
        if self:
            success_total = 0
            failure_total = 0
            ttl = kwargs.get("ttl", 3600)
Severity: Minor
Found in website/pushnotifications/models.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 setUpTestData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setUpTestData(cls) -> None:
        """Create the following test data:

        o0: an empty order
        o1: an unpaid order of 2 beer
Severity: Minor
Found in website/sales/tests/test_admin.py - About 1 hr to fix

Function setUpTestData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setUpTestData(cls) -> None:
        """Create the following test data:

        o0: an empty order
        o1: an unpaid order of 2 beer
Severity: Minor
Found in website/sales/tests/test_admin.py - About 1 hr to fix

Function __call__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def __call__(self, attrs, serializer):
        sources = [serializer.fields[field_name].source for field_name in self.fields]

        # If this is an update, then any unprovided field should
        # have it's value set based on the existing instance attribute.
Severity: Minor
Found in website/pizzas/api/v2/admin/validators.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 cancel_registration has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def cancel_registration(member, event):
    """Cancel a user registration for an event.

    :param member: the user
    :param event: the event
Severity: Minor
Found in website/events/services.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 render_main_menu has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def render_main_menu(context):
    """Render the main menu in this place.

    Accounts for logged-in status and locale.
    """
Severity: Minor
Found in website/thaliawebsite/templatetags/menu.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 prevent_saving_related has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def prevent_saving_related(foreign_key_field):
    def prevent_related_saving_paid_after_immutable(sender, instance, **kwargs):
        payable = payables.get_payable(getattr(instance, foreign_key_field))
        if not payable.immutable_after_payment:
            # Do nothing if the parent is not marked as immutable
Severity: Minor
Found in website/payments/payables.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 _retry_if_throttled has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def _retry_if_throttled():
    max_retries = 3

    def decorator_retry(func):
        @functools.wraps(func)
Severity: Minor
Found in website/moneybirdsynchronization/administration.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 test_sync_contacts has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def test_sync_contacts(
        self,
        mock_sync_contacts_with_outdated_mandates,
        mock_create_or_update_contact,
        mock_delete_contact,
Severity: Minor
Found in website/moneybirdsynchronization/tests/test_services.py - About 1 hr to fix

Function setUpTestData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setUpTestData(cls):
        """Create the following test data:

        o0: an empty order
        o1: an unpaid order of 2 beer
Severity: Minor
Found in website/sales/tests/test_api.py - About 1 hr to fix

Function setUpTestData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setUpTestData(cls):
        """Create the following test data:

        o0: an empty order
        o1: an unpaid order of 2 beer
Severity: Minor
Found in website/sales/tests/test_api.py - About 1 hr to fix

Function get_all_media has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_media(storage, minimum_file_age=None, folder=""):
    media = set()
    initial_time = timezone.now()

    if not storage.exists(folder):
Severity: Minor
Found in website/utils/management/commands/remove_unused_media.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 choices has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def choices(self, changelist):
        add_facets = changelist.add_facets
        facet_counts = self.get_facet_queryset(changelist)
        yield {
            "selected": self.lookup_val is None,
Severity: Minor
Found in website/promotion/admin.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 to_moneybird has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def to_moneybird(self):
        moneybird = get_moneybird_api_service()

        contact_id = settings.MONEYBIRD_UNKNOWN_PAYER_CONTACT_ID

Severity: Minor
Found in website/moneybirdsynchronization/models.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 clean has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

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

        if self.iban[0:2] != "NL" and not self.bic:
Severity: Minor
Found in website/payments/models.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 handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):
        if not settings.AWS_STORAGE_BUCKET_NAME:
            logging.error("No AWS settings found")
            return

Severity: Minor
Found in website/thaliawebsite/management/commands/migratemedia.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 test_shift_statistics has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def test_shift_statistics(self):
        self.assertEqual(self.shift.total_revenue, 0)
        self.assertEqual(self.shift.total_revenue_paid, 0)

        self.assertEqual(self.shift.num_orders, 0)
Severity: Minor
Found in website/sales/tests/test_models.py - About 1 hr to fix

Function setUpTestData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setUpTestData(cls):
        cls.member_no_mail = Member.objects.create(
            username="no_mail_test", first_name="Nomail", last_name="Example"
        )
        Profile.objects.create(
Severity: Minor
Found in website/members/tests/test_emails.py - About 1 hr to fix

Function _get_permissions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_permissions(user, obj):
        if not user.is_active or user.is_anonymous or obj is not None:
            return set()

        perm_cache_name = "_membergroup_perm_cache"
Severity: Minor
Found in website/activemembers/backends.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 save_model has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def save_model(self, request, obj, form, change):
        if change and "max_participants" in form.changed_data:
            prev = self.model.objects.get(id=obj.id)
            prev_limit = prev.max_participants
            self_limit = obj.max_participants
Severity: Minor
Found in website/events/admin/event.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

Severity
Category
Status
Source
Language