rspec/rules/S3729/rule.adoc
2021-01-27 13:42:22 +01:00

20 lines
455 B
Plaintext

While C syntax considers array subscripts (``++[]++``) as symmetrical, meaning that ``++a[i]++`` and ``++i[a]++`` are equivalent, the convention is to put the index in the brackets rather than the array name. Inverting the index and array name serves no purpose, and is very confusing.
== Noncompliant Code Example
----
10[P1] = 0; // Noncompliant
dostuff(i[arr]); // Noncompliant
----
== Compliant Solution
----
P1[10] = 0;
dostuff(arr[i]);
----