-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Replace this digraph 'xxx' by its equivalent 'yyy'.
-
Default Severity:Blocker
-
Impact:High
-
Likelihood:High
-
Default Quality Profiles:Sonar way
-
Legacy Key:DigraphUsage
-
Covered Languages:C, C++, Objective-C
-
Remediation Function:Constant/Issue
-
Constant Cost:5min
-
MISRA C++ 2008:2-5-1
-
PC-Lint:9102
The use of digraphs may not meet developer expectations.
The digraphs are:
- <%
- %>
- <:
- :>
- %:
- %:%:
Noncompliant Code Example
template <typename T> class A { public: template<int32_t i> void f2(); }; void f(A<int32_t> * a<:10:>) /* Noncompliant - usage of '<:' instead of '[' and ':>' instead of ']' */ <% /* Noncompliant - usage of '<%' instead of '{' */ a<:0:>->f2<20>(); /* Noncompliant - usage of '<:' and ':>' */ %> /* Noncompliant - usage of '%>' instead of '}' */
Compliant Solution
/* ... */ void f(A<int32_t> * a[10]) /* Compliant */ { /* Compliant */ a[0]->f2<20>(); /* Compliant */ } /* Compliant */
See
- MISRA C++:2008, 2-5-1 - Digraphs should not be used.
1.
|
C-Family | RSPEC-4357 |
|
Active | Unassigned |