post-condition-loop
What it does
Section titled “What it does”Reports begin ... end while cond and begin ... end until cond.
Why it matters
Section titled “Why it matters”This loop runs the body once before it tests the condition, unlike every other while or until, and readers expect the test first. loop do ... break if ... end says what happens.
To fix, write loop do, with break unless cond at the end of the body.
Example
Section titled “Example”...f == 0begin xend while ycase x...when 2 then z...Configuration
Section titled “Configuration”ruby: lint: rules: post-condition-loop: warn # off (default), warn, errorEnabled by the presets: ruby/rubocop.
Suppress one line with sudsy-disable-next-line post-condition-loop in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| rubocop | Lint/Loop |
full |