Inspectopedia
 
2024.3

'unless' statement with 'else'

Warning
New
Last modified: 03 December 2024

Reports unless statements used with else. It is preferable to put the positive branch first.

Example:

A quick-fix is available to convert an unless into if. After the quick-fix is applied, the result looks like this:

Inspired by 'Ruby Style Guide'