# Buggy code
def update_alerts(self):
    if (
        self.project.access_control == self.project.ACCESS_PUBLIC
        and not self.license
        and not getattr(settings, "LOGIN_REQUIRED_URLS", None)
    ):
        self.add_alert("MissingLicense")
    else:
        self.delete_alert("MissingLicense")

    # Pick random translation with translated strings except source one
    translation = (
        self.translation_set.filter(unit__state__gte=STATE_TRANSLATED)
        .exclude(language=self.project.source_language)
        .first()
    )
    if translation:
        allunits = translation.unit_set
    else:
        allunits = self.source_translation.unit_set

    source_space = allunits.filter(source__contains=" ")
    target_space = allunits.filter(state__gte=STATE_TRANSLATED, target__contains=" ")
    if (
        not self.template
        and allunits.count() > 3
        and not source_space.exists()
        and target_space.exists()
    ):
        self.add_alert("MonolingualTranslation")
    else:
        self.delete_alert("MonolingualTranslation")
    if not self.can_push():
        self.delete_alert("PushFailure")

    if self.vcs not in VCS_REGISTRY or self.file_format not in FILE_FORMATS:
        self.add_alert(
            "UnsupportedConfiguration",
            vcs=self.vcs not in VCS_REGISTRY,
            file_format=self.file_format not in FILE_FORMATS,
        )
    else:
        self.delete_alert("UnsupportedConfiguration")

    base = self.linked_component if self.is_repo_link else self
    masks = [base.filemask]
    masks.extend(base.linked_childs.values_list("filemask", flat=True))
    duplicates = [item for item, count in Counter(masks).items() if count > 1]
    if duplicates:
        self.add_alert("DuplicateFilemask", duplicates=duplicates)
    else:
        self.delete_alert("DuplicateFilemask")

    location_error = None
    location_link = None
    if self.repoweb:
        unit = allunits.exclude(location="").first()
        if unit:
            for _location, filename, line in unit.get_locations():
                location_link = self.get_repoweb_link(filename, line)
                if location_link is None:
                    continue
                # We only test first link
                location_error = get_uri_error(location_link)
                break
    if location_error:
        self.add_alert("BrokenBrowserURL", link=location_link, error=location_error)
    else:
        self.delete_alert("BrokenBrowserURL")
    if self.project.web:
        error = get_uri_error(self.project.web)
        if error is not None:
            self.add_alert("BrokenProjectURL", error=error)
        else:
            self.delete_alert("BrokenProjectURL")
    else:
        self.delete_alert("BrokenProjectURL")

    if self.screenshot_set.annotate(Count("units")).filter(units__count=0).exists():
        self.add_alert("UnusedScreenshot")
    else:
        self.delete_alert("UnusedScreenshot")


# Traceback (OperationalError)
weblate_1   | celery-main stderr | [2020-08-29 04:26:52,377: INFO/MainProcess] Received task: weblate.trans.tasks.component_removal[96b2ff92-8ef2-4da5-90be-0dc156759223]
weblate_1   | celery-main stderr | ERROR Failure while executing task: OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | [2020-08-29 04:27:05,722: ERROR/ForkPoolWorker-2269] Failure while executing task: OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | ERROR Failure while executing task: OperationalError: {'signal': <Signal: task_failure providing_args={'exception', 'kwargs', 'task_id', 'args', 'einfo', 'traceback'}>, 'sender': <@task: weblate.trans.tasks.component_removal of weblate at 0x7f9d9feae8d0>, 'task_id': 'be2f6bb8-94ab-4f4e-9e66-a76b7be38c12', 'args': [5821, 3], 'kwargs': {}, 'traceback': <traceback object at 0x7f9d822f5588>, 'einfo': <ExceptionInfo: OperationalError('deadlock detected\nDETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.\nProcess 24836 waits for ShareLock on transaction 105389; blocked by process 24833.\nHINT:  See server log for query details.\nCONTEXT:  while updating tuple (18,112) in relation "trans_alert"\n')>}
weblate_1   | celery-main stderr | [2020-08-29 04:27:05,722: ERROR/ForkPoolWorker-2269] Failure while executing task: OperationalError: {'signal': <Signal: task_failure providing_args={'exception', 'kwargs', 'task_id', 'args', 'einfo', 'traceback'}>, 'sender': <@task: weblate.trans.tasks.component_removal of weblate at 0x7f9d9feae8d0>, 'task_id': 'be2f6bb8-94ab-4f4e-9e66-a76b7be38c12', 'args': [5821, 3], 'kwargs': {}, 'traceback': <traceback object at 0x7f9d822f5588>, 'einfo': <ExceptionInfo: OperationalError('deadlock detected\nDETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.\nProcess 24836 waits for ShareLock on transaction 105389; blocked by process 24833.\nHINT:  See server log for query details.\nCONTEXT:  while updating tuple (18,112) in relation "trans_alert"\n')>}
weblate_1   | celery-main stderr | ERROR Failure while executing task
weblate_1   | celery-main stderr | Traceback (most recent call last):
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr | psycopg2.errors.DeadlockDetected: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr | The above exception was the direct cause of the following exception:
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | Traceback (most recent call last):
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 412, in trace_task
weblate_1   | celery-main stderr |     R = retval = fun(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 704, in __protected_call__
weblate_1   | celery-main stderr |     return self.run(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/celery.py", line 171, in _inner
weblate_1   | celery-main stderr |     reraise(*exc_info)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/_compat.py", line 57, in reraise
weblate_1   | celery-main stderr |     raise value
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/celery.py", line 166, in _inner
weblate_1   | celery-main stderr |     return f(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/tasks.py", line 299, in component_removal
weblate_1   | celery-main stderr |     obj.delete()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/utils/db.py", line 127, in delete
weblate_1   | celery-main stderr |     return collector.delete()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/deletion.py", line 436, in delete
weblate_1   | celery-main stderr |     sender=model, instance=obj, using=self.using
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/dispatch/dispatcher.py", line 179, in send
weblate_1   | celery-main stderr |     for receiver in self._live_receivers(sender)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/dispatch/dispatcher.py", line 179, in <listcomp>
weblate_1   | celery-main stderr |     for receiver in self._live_receivers(sender)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/utils/decorators.py", line 30, in wrapper
weblate_1   | celery-main stderr |     signal_handler(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/__init__.py", line 223, in post_delete_linked
weblate_1   | celery-main stderr |     instance.linked_component.update_alerts()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 2313, in update_alerts
weblate_1   | celery-main stderr |     self.add_alert("DuplicateFilemask", duplicates=duplicates)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1629, in add_alert
weblate_1   | celery-main stderr |     component.add_alert(alert, **details)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1626, in add_alert
weblate_1   | celery-main stderr |     obj.save()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/alert.py", line 61, in save
weblate_1   | celery-main stderr |     super().save(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 751, in save
weblate_1   | celery-main stderr |     force_update=force_update, update_fields=update_fields)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 789, in save_base
weblate_1   | celery-main stderr |     force_update, using, update_fields,
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 870, in _save_table
weblate_1   | celery-main stderr |     forced_update)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 923, in _do_update
weblate_1   | celery-main stderr |     return filtered._update(values) > 0
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/query.py", line 803, in _update
weblate_1   | celery-main stderr |     return query.get_compiler(self.db).execute_sql(CURSOR)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1515, in execute_sql
weblate_1   | celery-main stderr |     cursor = super().execute_sql(result_type)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql
weblate_1   | celery-main stderr |     cursor.execute(sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/django/__init__.py", line 489, in execute
weblate_1   | celery-main stderr |     return real_execute(self, sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 66, in execute
weblate_1   | celery-main stderr |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
weblate_1   | celery-main stderr |     return executor(sql, params, many, context)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/utils.py", line 90, in __exit__
weblate_1   | celery-main stderr |     raise dj_exc_value.with_traceback(traceback) from exc_value
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr | django.db.utils.OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | [2020-08-29 04:27:05,723: ERROR/ForkPoolWorker-2269] Failure while executing task
weblate_1   | celery-main stderr | Traceback (most recent call last):
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr | psycopg2.errors.DeadlockDetected: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | The above exception was the direct cause of the following exception:
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | Traceback (most recent call last):
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 412, in trace_task
weblate_1   | celery-main stderr |     R = retval = fun(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/celery/app/trace.py", line 704, in __protected_call__
weblate_1   | celery-main stderr |     return self.run(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/celery.py", line 171, in _inner
weblate_1   | celery-main stderr |     reraise(*exc_info)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/_compat.py", line 57, in reraise
weblate_1   | celery-main stderr |     raise value
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/celery.py", line 166, in _inner
weblate_1   | celery-main stderr |     return f(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/tasks.py", line 299, in component_removal
weblate_1   | celery-main stderr |     obj.delete()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/utils/db.py", line 127, in delete
weblate_1   | celery-main stderr |     return collector.delete()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/deletion.py", line 436, in delete
weblate_1   | celery-main stderr |     sender=model, instance=obj, using=self.using
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/dispatch/dispatcher.py", line 179, in send
weblate_1   | celery-main stderr |     for receiver in self._live_receivers(sender)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/dispatch/dispatcher.py", line 179, in <listcomp>
weblate_1   | celery-main stderr |     for receiver in self._live_receivers(sender)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/utils/decorators.py", line 30, in wrapper
weblate_1   | celery-main stderr |     signal_handler(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/__init__.py", line 223, in post_delete_linked
weblate_1   | celery-main stderr |     instance.linked_component.update_alerts()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 2313, in update_alerts
weblate_1   | celery-main stderr |     self.add_alert("DuplicateFilemask", duplicates=duplicates)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1629, in add_alert
weblate_1   | celery-main stderr |     component.add_alert(alert, **details)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1626, in add_alert
weblate_1   | celery-main stderr |     obj.save()
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/alert.py", line 61, in save
weblate_1   | celery-main stderr |     super().save(*args, **kwargs)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 751, in save
weblate_1   | celery-main stderr |     force_update=force_update, update_fields=update_fields)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 789, in save_base
weblate_1   | celery-main stderr |     force_update, using, update_fields,
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 870, in _save_table
weblate_1   | celery-main stderr |     forced_update)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 923, in _do_update
weblate_1   | celery-main stderr |     return filtered._update(values) > 0
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/query.py", line 803, in _update
weblate_1   | celery-main stderr |     return query.get_compiler(self.db).execute_sql(CURSOR)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1515, in execute_sql
weblate_1   | celery-main stderr |     cursor = super().execute_sql(result_type)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql
weblate_1   | celery-main stderr |     cursor.execute(sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/sentry_sdk/integrations/django/__init__.py", line 489, in execute
weblate_1   | celery-main stderr |     return real_execute(self, sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 66, in execute
weblate_1   | celery-main stderr |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
weblate_1   | celery-main stderr |     return executor(sql, params, many, context)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/utils.py", line 90, in __exit__
weblate_1   | celery-main stderr |     raise dj_exc_value.with_traceback(traceback) from exc_value
weblate_1   | celery-main stderr |   File "/usr/local/lib/python3.7/dist-packages/django/db/backends/utils.py", line 84, in _execute
weblate_1   | celery-main stderr |     return self.cursor.execute(sql, params)
weblate_1   | celery-main stderr | django.db.utils.OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24833 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | Process 24836 waits for ShareLock on transaction 105389; blocked by process 24833.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,112) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-notify stderr | [2020-08-29 04:27:06,718: INFO/MainProcess] Received task: weblate.accounts.tasks.notify_change[1b04ef9b-e548-4b08-9dee-04cd869c86a9]
weblate_1   | celery-main stderr | [2020-08-29 04:27:08,421: INFO/MainProcess] Received task: weblate.trans.tasks.component_removal[5527a8f2-4af9-45b7-bae7-37ba4d32b7c9]
weblate_1   | celery-main stderr | ERROR Failure while executing task: OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24836 waits for ShareLock on transaction 105393; blocked by process 24839.
weblate_1   | celery-main stderr | Process 24839 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,113) in relation "trans_alert"
weblate_1   | celery-main stderr |
weblate_1   | celery-main stderr | [2020-08-29 04:27:24,429: ERROR/ForkPoolWorker-2270] Failure while executing task: OperationalError: deadlock detected
weblate_1   | celery-main stderr | DETAIL:  Process 24836 waits for ShareLock on transaction 105393; blocked by process 24839.
weblate_1   | celery-main stderr | Process 24839 waits for ShareLock on transaction 105391; blocked by process 24836.
weblate_1   | celery-main stderr | HINT:  See server log for query details.
weblate_1   | celery-main stderr | CONTEXT:  while updating tuple (18,113) in relation "trans_alert"
weblate_1   | celery-main stderr |

# Fixed code
def update_alerts(self):
    if (
        self.project.access_control == self.project.ACCESS_PUBLIC
        and not self.license
        and not getattr(settings, "LOGIN_REQUIRED_URLS", None)
    ):
        self.add_alert("MissingLicense")
    else:
        self.delete_alert("MissingLicense")

    # Pick random translation with translated strings except source one
    translation = (
        self.translation_set.filter(unit__state__gte=STATE_TRANSLATED)
        .exclude(language=self.project.source_language)
        .first()
    )
    if translation:
        allunits = translation.unit_set
    else:
        allunits = self.source_translation.unit_set

    source_space = allunits.filter(source__contains=" ")
    target_space = allunits.filter(state__gte=STATE_TRANSLATED, target__contains=" ")
    if (
        not self.template
        and allunits.count() > 3
        and not source_space.exists()
        and target_space.exists()
    ):
        self.add_alert("MonolingualTranslation")
    else:
        self.delete_alert("MonolingualTranslation")
    if not self.can_push():
        self.delete_alert("PushFailure")

    if self.vcs not in VCS_REGISTRY or self.file_format not in FILE_FORMATS:
        self.add_alert(
            "UnsupportedConfiguration",
            vcs=self.vcs not in VCS_REGISTRY,
            file_format=self.file_format not in FILE_FORMATS,
        )
    else:
        self.delete_alert("UnsupportedConfiguration")

    location_error = None
    location_link = None
    if self.repoweb:
        unit = allunits.exclude(location="").first()
        if unit:
            for _location, filename, line in unit.get_locations():
                location_link = self.get_repoweb_link(filename, line)
                if location_link is None:
                    continue
                # We only test first link
                location_error = get_uri_error(location_link)
                break
    if location_error:
        self.add_alert("BrokenBrowserURL", link=location_link, error=location_error)
    else:
        self.delete_alert("BrokenBrowserURL")
    if self.project.web:
        error = get_uri_error(self.project.web)
        if error is not None:
            self.add_alert("BrokenProjectURL", error=error)
        else:
            self.delete_alert("BrokenProjectURL")
    else:
        self.delete_alert("BrokenProjectURL")

    if self.screenshot_set.annotate(Count("units")).filter(units__count=0).exists():
        self.add_alert("UnusedScreenshot")
    else:
        self.delete_alert("UnusedScreenshot")

    self.update_link_alerts()