Skip to content

Files

Latest commit

 

History

History
32 lines (23 loc) · 669 Bytes

Style-OptionalBooleanParameter.md

File metadata and controls

32 lines (23 loc) · 669 Bytes

Pattern: Missing use of keyword argument

Issue: -

Description

This rule checks for places where keyword arguments can be used instead of boolean arguments when defining methods.

Examples

# bad
def some_method(bar = false)
  puts bar
end

# bad - common hack before keyword args were introduced
def some_method(options = {})
  bar = options.fetch(:bar, false)
  puts bar
end

# good
def some_method(bar: false)
  puts bar
end

Further Reading