rspec/rules/S3358/cfamily/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

42 lines
953 B
Plaintext

== Why is this an issue?
:noncompliant: cfamily/noncompliant.adoc
:compliant: cfamily/compliant.adoc
include::../description.adoc[]
=== Exceptions
In {cpp}11, the rule ignores ternary operators inside `constexpr` functions.
Indeed, in {cpp}11, such functions are limited to just a return statement, so using a ternary operator might be required. Later standards lifted this restriction, so this exception does not apply to them.
[source,cpp]
----
constexpr int max(int p1, int p2, int p3) {
return p1 > p2 ? (p1 > p3 ? p1 : p3) : (p2 > p3 ? p2 : p3); // Compliant by exception in C++11
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Extract this nested conditional operator into an independent statement.
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]