Skip to content

Commit 380c7b2

Browse files
Update metadata (#262)
1 parent 3f031e5 commit 380c7b2

16 files changed

+253
-100
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Programmers should not comment out code as it bloats programs and reduces readability.</p>
3-
<p>Unused code should be deleted and can be retrieved from source control history if required.</p>
2+
<p>Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never
3+
executed, it quickly becomes out of date and invalid.</p>
4+
<p>Commented-out code should be deleted and can be retrieved from source control history if required.</p>
45

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/AvoidHtmlCommentCheck.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ <h2>Compliant Solution</h2>
3434
</pre>
3535
<h2>See</h2>
3636
<ul>
37-
<li> <a href="https://www.owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure">OWASP Top 10 2017 Category A3</a> - Sensitive Data
38-
Exposure </li>
39-
<li> <a href="https://cwe.mitre.org/data/definitions/615">MITRE, CWE-615</a> - Information Exposure Through Comments </li>
37+
<li> OWASP - <a href="https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure">Top 10 2017 Category A3 - Sensitive Data
38+
Exposure</a> </li>
39+
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/615">CWE-615 - Information Exposure Through Comments</a> </li>
4040
</ul>
4141

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/AvoidHtmlCommentCheck.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"title": "Using HTML comments is security-sensitive",
3-
"type": "SECURITY_HOTSPOT",
2+
"title": "HTML comments should be removed",
3+
"type": "CODE_SMELL",
44
"status": "ready",
55
"remediation": {
66
"func": "Constant\/Issue",
@@ -21,5 +21,6 @@
2121
"OWASP": [
2222
"A3"
2323
]
24-
}
24+
},
25+
"quickfix": "unknown"
2526
}

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/ImgWithoutAltCheck.html

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,58 @@ <h2>Why is this an issue?</h2>
55
<ul>
66
<li> The image can no longer be found </li>
77
<li> Visually impaired users using a screen reader software </li>
8-
<li> Images loading is disabled, to reduce data consumption on mobile phones </li>
8+
<li> Image loading is disabled, to reduce data consumption on mobile phones </li>
99
</ul>
10-
<p>It is also very important to not set an <code>alt</code> attribute to a non-informative value. For example <code>&lt;img ... alt="logo"&gt;</code>
10+
<p>It is also very important not to set an <code>alt</code> attribute to a non-informative value. For example, <code>&lt;img ... alt="logo"&gt;</code>
1111
is useless as it doesn’t give any information to the user. In this case, as for any other decorative image, it is better to use a CSS background image
12-
instead of an <code>&lt;img&gt;</code> tag. If using CSS background-image is not possible, an empty <code>alt=""</code> is tolerated. See Exceptions
13-
bellow.</p>
14-
<p>This rule raises an issue when</p>
12+
instead of an <code>&lt;img&gt;</code> tag. If using CSS <code>background-image</code> is not possible, an empty <code>alt=""</code> is tolerated. See
13+
Exceptions below.</p>
14+
<p>This rule raises an issue when:</p>
1515
<ul>
16-
<li> an <code>&lt;input type="image"&gt;</code> tag or an <code>&lt;area&gt;</code> tag have no <code>alt</code> attribute or their
17-
<code>alt</code>&nbsp;attribute has an empty string value. </li>
18-
<li> an <code>&lt;img&gt;</code> tag has no <code>alt</code> attribute. </li>
16+
<li> An <code>&lt;input type="image"&gt;</code> or <code>&lt;area&gt;</code> element has no <code>alt</code> attribute or it holds an empty string
17+
value. </li>
18+
<li> An <code>&lt;img&gt;</code> element has no <code>alt</code> attribute. </li>
1919
</ul>
20-
<h3>Noncompliant code example</h3>
20+
<h3>Exceptions</h3>
21+
<p><code>&lt;img&gt;</code> elements with an empty string&nbsp;<code>alt=""</code> attribute won’t raise any issue. However, this way should be used
22+
in two cases only:</p>
23+
<p>When the image is decorative and it is not possible to use a CSS background image. For example, when the decorative <code>&lt;img&gt;</code> is
24+
generated via javascript with a source image coming from a database, it is better to use an <code>&lt;img alt=""&gt;</code> tag rather than generate
25+
CSS code.</p>
2126
<pre>
22-
&lt;img src="foo.png" /&gt; &lt;!-- Noncompliant --&gt;
23-
&lt;input type="image" src="bar.png" /&gt; &lt;!-- Noncompliant --&gt;
24-
&lt;input type="image" src="bar.png" alt="" /&gt; &lt;!-- Noncompliant --&gt;
27+
&lt;li *ngFor="let image of images"&gt;
28+
&lt;img [src]="image" alt=""&gt;
29+
&lt;/li&gt;
30+
</pre>
31+
<p>When the image is not decorative but its <code>alt</code> text would repeat a nearby text. For example, images contained in links should not
32+
duplicate the link’s text in their <code>alt</code> attribute, as it would make the screen reader repeat the text twice.</p>
33+
<pre>
34+
&lt;a href="flowers.html"&gt;
35+
&lt;img src="tulip.gif" alt="" /&gt;
36+
A blooming tulip
37+
&lt;/a&gt;
38+
</pre>
39+
<p>In all other cases you should use CSS background images.</p>
40+
<h2>How to fix it</h2>
41+
<p>Add an alternative text to the HTML element.</p>
42+
<h3>Code examples</h3>
43+
<h4>Noncompliant code example</h4>
44+
<pre data-diff-id="1" data-diff-type="noncompliant">
45+
&lt;img src="foo.png" /&gt; &lt;!-- missing `alt` attribute --&gt;
46+
&lt;input type="image" src="bar.png" /&gt; &lt;!-- missing `alt` attribute --&gt;
47+
&lt;input type="image" src="bar.png" alt="" /&gt; &lt;!-- empty `alt` attribute on &lt;input&gt; --&gt;
2548

2649
&lt;img src="house.gif" usemap="#map1"
2750
alt="rooms of the house." /&gt;
2851
&lt;map id="map1" name="map1"&gt;
2952
&lt;area shape="rect" coords="0,0,42,42"
30-
href="bedroom.html"/&gt; &lt;!-- Noncompliant --&gt;
53+
href="bedroom.html"/&gt; &lt;!-- missing `alt` attribute --&gt;
3154
&lt;area shape="rect" coords="0,0,21,21"
32-
href="lounge.html" alt=""/&gt; &lt;!-- Noncompliant --&gt;
55+
href="lounge.html" alt=""/&gt; &lt;!-- empty `alt` attribute on &lt;area&gt; --&gt;
3356
&lt;/map&gt;
3457
</pre>
35-
<h3>Compliant solution</h3>
36-
<pre>
58+
<h4>Compliant solution</h4>
59+
<pre data-diff-id="1" data-diff-type="compliant">
3760
&lt;img src="foo.png" alt="Some textual description of foo.png" /&gt;
3861
&lt;input type="image" src="bar.png" alt="Textual description of bar.png" /&gt;
3962

@@ -46,38 +69,18 @@ <h3>Compliant solution</h3>
4669
href="lounge.html" alt="Lounge"/&gt;
4770
&lt;/map&gt;
4871
</pre>
49-
<h3>Exceptions</h3>
50-
<p><code>&lt;img&gt;</code> tags with empty string&nbsp;<code>alt=""</code> attributes won’t raise any issue. However this technic should be used in
51-
two cases only:</p>
52-
<p>When the image is decorative and it is not possible to use a CSS background image. For example, when the decorative <code>&lt;img&gt;</code> is
53-
generated via javascript with a source image coming from a database, it is better to use an <code>&lt;img alt=""&gt;</code> tag rather than generate
54-
CSS code.</p>
55-
<pre>
56-
&lt;li *ngFor="let image of images"&gt;
57-
&lt;img [src]="image" alt=""&gt;
58-
&lt;/li&gt;
59-
</pre>
60-
<p>When the image is not decorative but it’s <code>alt</code> text would repeat a nearby text. For example, images contained in links should not
61-
duplicate the link’s text in their <code>alt</code> attribute, as it would make the screen reader repeat the text twice.</p>
62-
<pre>
63-
&lt;a href="flowers.html"&gt;
64-
&lt;img src="tulip.gif" alt="" /&gt;
65-
A blooming tulip
66-
&lt;/a&gt;
67-
</pre>
68-
<p>In all other cases you should use CSS background images.</p>
69-
<p>See&nbsp;<a href="https://www.w3.org/WAI/tutorials/images/decision-tree/">W3C WAI&nbsp;Web Accessibility Tutorials</a>&nbsp;for more
70-
information.</p>
7172
<h2>Resources</h2>
73+
<h3>Documentation</h3>
7274
<ul>
73-
<li> <a href="https://www.w3.org/TR/WCAG20-TECHS/H24.html">WCAG2, H24</a> - Providing text alternatives for the area elements of image maps </li>
74-
<li> <a href="https://www.w3.org/TR/WCAG20-TECHS/H36.html">WCAG2, H36</a> - Using alt attributes on images used as submit buttons </li>
75-
<li> <a href="https://www.w3.org/TR/WCAG20-TECHS/H37.html">WCAG2, H37</a> - Using alt attributes on img elements </li>
76-
<li> <a href="https://www.w3.org/TR/WCAG20-TECHS/H67.html">WCAG2, H67</a> - Using null alt text and no title attribute on img elements for images
77-
that AT should ignore </li>
78-
<li> <a href="https://www.w3.org/TR/WCAG20-TECHS/H2.html">WCAG2, H2</a> - Combining adjacent image and text links for the same resource </li>
79-
<li> <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-text-equiv-all">WCAG2, 1.1.1</a> - Non-text Content </li>
80-
<li> <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-navigation-mechanisms-refs">WCAG2, 2.4.4</a> - Link Purpose (In Context) </li>
81-
<li> <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-navigation-mechanisms-link">WCAG2, 2.4.9</a> - Link Purpose (Link Only) </li>
75+
<li> W3C - <a href="https://www.w3.org/WAI/tutorials/images/decision-tree/">W3C WAI&nbsp;Web Accessibility Tutorials</a> </li>
76+
<li> W3C - <a href="https://www.w3.org/TR/WCAG20-TECHS/H24.html">Providing text alternatives for the area elements of image maps</a> </li>
77+
<li> W3C - <a href="https://www.w3.org/TR/WCAG20-TECHS/H36.html">Using alt attributes on images used as submit buttons</a> </li>
78+
<li> W3C - <a href="https://www.w3.org/TR/WCAG20-TECHS/H37.html">Using alt attributes on img elements</a> </li>
79+
<li> W3C - <a href="https://www.w3.org/TR/WCAG20-TECHS/H67.html">Using null alt text and no title attribute on img elements for images that AT
80+
should ignore</a> </li>
81+
<li> W3C - <a href="https://www.w3.org/TR/WCAG20-TECHS/H2.html">Combining adjacent image and text links for the same resource</a> </li>
82+
<li> W3C - <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-text-equiv-all">Non-text Content</a> </li>
83+
<li> W3C - <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-navigation-mechanisms-refs">Link Purpose (In Context)</a> </li>
84+
<li> W3C - <a href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-navigation-mechanisms-link">Link Purpose (Link Only)</a> </li>
8285
</ul>
8386

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/ImgWithoutAltCheck.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"title": "Image, area and button with image tags should have an \"alt\" attribute",
3-
"type": "BUG",
2+
"title": "Image, area and button with image elements should have an \"alt\" attribute",
3+
"type": "CODE_SMELL",
44
"code": {
55
"impacts": {
66
"RELIABILITY": "LOW"
@@ -20,5 +20,5 @@
2020
"ruleSpecification": "RSPEC-1077",
2121
"sqKey": "ImgWithoutAltCheck",
2222
"scope": "Main",
23-
"quickfix": "unknown"
23+
"quickfix": "infeasible"
2424
}

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/LongJavaScriptCheck.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Javascript scriptlets should not have too many lines of code",
2+
"title": "JavaScript scriptlets should not have too many lines of code",
33
"type": "CODE_SMELL",
44
"code": {
55
"impacts": {

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/S1134.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ <h2>Why is this an issue?</h2>
1111
<h2>Resources</h2>
1212
<h3>Documentation</h3>
1313
<ul>
14-
<li> <a href="https://cwe.mitre.org/data/definitions/546">MITRE, CWE-546 - Suspicious Comment</a> </li>
14+
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a> </li>
1515
</ul>
1616

sonar-html-plugin/src/main/resources/org/sonar/l10n/web/rules/Web/S1135.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Developers often use <code>TOOO</code> tags to mark areas in the code where additional work or improvements are needed but are not implemented
2+
<p>Developers often use <code>TODO</code> tags to mark areas in the code where additional work or improvements are needed but are not implemented
33
immediately. However, these <code>TODO</code> tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This code smell
44
class aims to identify and address such unattended <code>TODO</code> tags to ensure a clean and maintainable codebase. This description will explore
55
why this is a problem and how it can be fixed to improve the overall code quality.</p>
@@ -24,6 +24,6 @@ <h3>Noncompliant code example</h3>
2424
</pre>
2525
<h2>Resources</h2>
2626
<ul>
27-
<li> <a href="https://cwe.mitre.org/data/definitions/546">MITRE, CWE-546</a> - Suspicious Comment </li>
27+
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a> </li>
2828
</ul>
2929

0 commit comments

Comments
 (0)