
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.
59 lines
1.3 KiB
Plaintext
59 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Nested conditionals are hard to read and can make the order of operations complex to understand.
|
|
|
|
[source,python]
|
|
----
|
|
class Job:
|
|
@property
|
|
def readable_status(self):
|
|
return "Running" if job.is_running else "Failed" if job.errors else "Succeeded" # Noncompliant
|
|
----
|
|
|
|
Instead, use another line to express the nested operation in a separate statement.
|
|
|
|
[source,python]
|
|
----
|
|
class Job:
|
|
@property
|
|
def readable_status(self):
|
|
if job.is_running:
|
|
return "Running"
|
|
return "Failed" if job.errors else "Succeeded"
|
|
----
|
|
|
|
=== Exceptions
|
|
|
|
No issue is raised on conditional expressions in comprehensions.
|
|
|
|
[source,python]
|
|
----
|
|
job_statuses = ["Running" if job.is_running else "Failed" if job.errors else "Succeeded" for job in jobs] # Compliant by exception
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Extract this nested conditional expression into an independent statement.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
* Primary: highlight the entire nested conditional expression
|
|
* Secondary: highlight the "if" and "else" of the parent conditional expression
|
|
message: 'Parent conditional expression.'
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|