rspec/rules/S3936/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

74 lines
1.1 KiB
Plaintext

== Why is this an issue?
The GNU compiler extension that allows ``++case++``s to be specified with ranges should only be used when a range is actually needed. Use it with the same number on both ends of the range, and you've either made a mistake because an actual range was intended, or you've used the syntax inappropriately in a way that is highly likely to confuse maintainers.
=== Noncompliant code example
[source,cpp]
----
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3 ... 3: // Noncompliant
//...
break;
}
----
=== Compliant solution
[source,cpp]
----
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3:
//...
break;
}
----
or
[source,cpp]
----
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3 ... 5:
//...
break;
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Update this range to cover more than one value or refactor it to remove the range syntax.
=== Highlighting
``++x ... x++``
endif::env-github,rspecator-view[]