Convention: use colon as separator in comments within code blocks (#4425)

Co-authored-by: Loïc Joly <loic.joly@sonarsource.com>
This commit is contained in:
Antonio Aversa 2024-10-21 10:27:29 +02:00 committed by GitHub
parent 4d35623ab6
commit 3837a175d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -271,14 +271,22 @@ tsql:: use `sql`
In case no language is appropriate for a code block (for example shared examples between multiple languages), you can use `text` as the language.
=== References within code blocks
=== Comments within code blocks
Colon (`:`) should be used as separator between `Noncompliant`/`Compliant` comments and the text explanation that follows, if any.
[source,cpp]
----
int X = 2; // Noncompliant: variable should be in lowercase
----
When referencing a name within a comment in a code example, use double quotes to make it clear it refers to an existing element in the code.
[source,cpp]
----
int i = 0;
cout << noexcept(++i); // Noncompliant, "i" is not incremented
cout << noexcept(++i); // Noncompliant: "i" is not incremented
----
=== Diff view