-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Message:Remove the misleading "[//|/*]" characters.
-
Default Severity:Minor
-
Impact:Low
-
Likelihood:Low
-
Default Quality Profiles:Sonar way
-
Legacy Key:NestedCommentsCheck
-
Targeted languages:C#, Flex, Java, JavaScript, Swift
-
Covered Languages:C, C++, Objective-C, PL/I, PL/SQL
-
Irrelevant for Languages:PHP, Python, T-SQL
-
Remediation Function:Constant/Issue
-
Constant Cost:2min
-
CERT:MSC04-C.
-
PC-Lint:602, 1602, 9059, 9066
Defining a nested single-line comment within a multi-line comment invites errors. It may lead a developer to wrongly think that the lines located after the single-line comment are not part of the comment.
If a comment starting sequence, / or //, occurs within a / comment, is it quite likely to be caused by a missing */ comment ending sequence.
If a comment starting sequence occurs within a // comment, it is probably because a region of code has been commented-out using //.
Noncompliant Code Example
/* some comment, end comment marker accidentally omitted // Make sure this function is called in a thread safe context Perform_Critical_Safety_Function(X); ... /* this comment is non-compliant */
See
- CERT, MSC04-C. - Use comments consistently and in a readable fashion
- deprecates
-
RSPEC-788 The character sequence /* shall not be used within a comment
- Closed
-
RSPEC-2523 Comments should not be nested
- Deprecated
- is implemented by
-
CPP-387 Rule: A C style comment "/* ... */" shall not contain a nested C++ style comment "// ..."
-
- Closed
-
-
SONARPLI-200 Rule S1103: Comments should not be nested
-
- Closed
-
-
CPP-707 Create Objective-C rules repository containing targeted rules
-
- Closed
-
- is related to
-
RSPEC-787 Source code should only use /* ... */ style comments
- Active
-
RSPEC-1917 Comment styles "//" and "/* ... */" should not be mixed within a file
- Active
1.
|
PL/SQL: Comments should not be nested | RSPEC-2619 |
|
Active | Unassigned | |
2.
|
C-Family | RSPEC-4228 |
|
Active | Unassigned | |
3.
|
PL/I: Comments should not be nested | RSPEC-6157 |
|
Active | Unassigned |