Skip to content

Commit

Permalink
fix(sonarcloud): ignore ul-wrapping of li with //NOSONAR, django does it
Browse files Browse the repository at this point in the history
SonarCloud was raising a reliability issue on the <li> tag line:
> Surround this <li> item tag by a <ul> or <ol> container one.
> "<li>" and "<dt>" item tags should be in "<ul>", "<ol>" or "<dl>"
> container tags Web:ItemTagNotWithinContainerTagCheck

This is a false positive issue as Django's default
admin/change_list.html wraps the object-tools-items inside <ul>...</ul>
tag, see
https://github.com/django/django/blob/4.2.18/django/contrib/admin/templates/admin/change_list.html#L44-L48

"//NOSONAR" is a bit of a blunt object, as it ignores all SonarCloud
issues on the given line. Ignoring a specific SonarCloud rule for
specific files using `sonar.issue.ignore.multicriteria` would possibly
work also, and be more rule specific, although not as line specific.

refs KK-1416
  • Loading branch information
karisal-anders committed Feb 20, 2025
1 parent 35932bd commit 82b09d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/templates/notification_change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block object-tools-items %}
{{ block.super }}
<li>
<li> <!-- //NOSONAR No need to wrap with <ul> here, base template does that -->
<a href="{% url 'admin:import-new-notifications' %}" class="btn btn-high btn-success">{% trans "Import new notifications from the spreadsheet" %}</a>
</li>
{% endblock %}
2 changes: 1 addition & 1 deletion importers/templates/notification_change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block object-tools-items %}
{{ block.super }}
<li>
<li> <!-- //NOSONAR No need to wrap with <ul> here, base template does that -->
<a href="{% url 'admin:import-missing-notifications' %}" class="btn btn-high btn-success">{% trans "Import missing notifications from the spreadsheet" %}</a>
</li>
{% endblock %}

0 comments on commit 82b09d2

Please sign in to comment.