By DeepSource

Use Range#cover? instead of Range#include? RB-PR1014


Range#include? iterates over each item in a Range to see if a specified item is there. In contrast, Range#cover? simply compares the target item with the beginning and end points of the Range. In a great majority of cases, this is what is wanted.

For example:


can be replaced by


The raised issue can be ignored in certain cases, like this, where Range#cover? may not provide the desired result.