The rule is to define it as an array if it is not necessary to describe it in the case statement.
Added with rubocop 0.88.0
, it's very good.
bad example
type = 'test'
case type
when 'interview'
'interview'
when 'test'
'test'
when 'standard'
'Normal'
end
Good example
type = 'test'
lists = {
'interview' => 'interview',
'test' => 'test',
'standard' => 'Normal',
}
lists[type]
https://github.com/rubocop-hq/rubocop/issues/8247
https://github.com/rubocop-hq/rubocop/pull/8280