Medium Ruby

Explicit return values in methods

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?
```

Included in Rulesets

Rails Standards
36 rules • 1 standard
View
Ruby Style Guide
25 rules • 1 standard
View
Code Review Standards
58 rules • 0 standards
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
Medium
Category
Ruby
Used in
3 rulesets