
Provide consistent examples for CFamily, CSharp, and Java. Make JS, PHP, Apex, Go, Kotlin, and Scala consistent. Python has its own syntax so inline relevant bits. Other languages are not updated: their description is considered good enough and it would require a significant investment to not mess up the syntax in their examples.
24 lines
380 B
Plaintext
24 lines
380 B
Plaintext
include::./why.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,{lang},diff-id=1,diff-type=noncompliant]
|
|
----
|
|
int x = ((y / 2 + 1)); // Noncompliant
|
|
|
|
if (a && ((x + y > 0))) { // Noncompliant
|
|
return ((x + 1)); // Noncompliant
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,{lang},diff-id=1,diff-type=compliant]
|
|
----
|
|
int x = (y / 2 + 1);
|
|
|
|
if (a && (x + y > 0)) {
|
|
return (x + 1);
|
|
}
|
|
----
|