Medium
Ruby
Explicit return values in methods
Official
Rule Description
Be intentional about method return values:
- Methods that perform actions should return meaningful results or self
- Query methods should return the queried value
- Predicate methods (ending in ?) should return true/false
- Bang methods (ending in !) should modify in place or raise
```ruby
# Good: Clear intent
def process_order
validate!
charge_payment
send_confirmation
self # Allow chaining
end
# Good: Predicate returns boolean
def valid? = errors.empty?
```
Add This Rule
Sign in to add this rule to your workspace
Sign in with GitHubDetails
- Severity
- Medium
- Category
- Ruby
- Used in
- 3 rulesets