Skip to content

Disable cop Style/SingleArgumentDig

Lin Jen-Shin requested to merge disable-cop-single-arg-dig into master

What does this MR do and why?

Disable cop Style/SingleArgumentDig

Because I don't agree with it. What if we do this?

data.dig(0, 1)
data.dig(0)
data.dig(0, 0)

It will look quite odd if we're forced to write as:

data.dig(0, 1)
data[0]
data.dig(0, 0)

The cop can be more smart to allow this case, but I don't think it's worth the complexity. If we want to be really consistent, I would prefer if we just disallow using [] because dig can do everything [] can do, if it's an array or a hash. It will be different for strings though! This means this will not be something static analysis can do, unfortunately.

This was discovered from !252 (diffs)

Edited by Lin Jen-Shin

Merge request reports