rspec/rules/S108/ruby/rule.adoc

54 lines
884 B
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
[source,ruby]
----
def compute(a, b)
sum = a + b
if sum > 0 # Noncompliant; empty on purpose or missing piece of code?
end
puts "Result: #{sum}"
end
----
=== Compliant solution
[source,ruby]
----
def compute(a, b)
sum = a + b
if sum > 0
puts "Positive result"
end
puts "Result: #{sum}"
end
----
=== Exceptions
When a block contains a comment, this block is not considered to be empty.
``++while++`` and ``++unless++`` loops are also exception to the rule.
----
while @order.process_next; end # Compliant
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]