rspec/rules/S2048/php/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

64 lines
1.3 KiB
Plaintext

== Why is this an issue?
Shared coding conventions allow teams to collaborate effectively.
This rule checks that when
* an assignment is too long to fit on one line, the line break is inserted before the ``++=++`` rather than after, and the second line of the statement is indented from the first.
* an object operator is the first thing on the line, it is indented from the previous line.
=== Noncompliant code example
[source,php]
----
$variable_with_a_very_very_long_name = classInstance.method1().method2().
method3(); // Noncompliant, linebreak after '='
$variable_with_a_very_very_long_name
= classInstance.method1().method2().method3(); // Noncompliant, 2nd line not indented
$a = classInstance.method1().method2().method3()
->property1; // Noncompliant,
----
=== Compliant solution
[source,php]
----
$variable_with_a_very_very_long_name
= classInstance.method1().method2().method3();
$a = classInstance.method1().method2().method3()
->property1;
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Indent this line {n} spaces.
* Break this assignment before "=", not after.
=== Parameters
.number_of_spaces
****
----
4
----
The number of spaces the second line should be intended from the first.
****
endif::env-github,rspecator-view[]