As you can see in the reference link, there is a way to print the message to stop using
% in RuboCop and use
In the same way, can I stop using
hoge[1,2] in the array and use
Because it is easy to mix with
values_at, I think issuing a warning to use slice will make it easier for you to notice that you used it as
As the person who answered earlier said, there is no such Cop (Cop, by the way, is a unit of rules in RuboCop).
Also, I think there will be a lot of false positive warnings, so even if you create such a Cop, RuboCop will not include it.
For example, the String class also defines the
Therefore, simply looking at the code,
hoge[1,2] cannot distinguish whether it is a method call to Array or a String, which causes false positives.
So why don't you use another tool instead of RuboCop?
For example, with a tool called query, you can easily define these rules yourself.
You can save the above information as
query.yaml and run the command
query check. to perform the expected inspection.
This tool is distributed in Rubygems and can be installed as
gem install query.
If there was a Cop like that, I looked it up based on the prediction that searching repository on slice would be part of the indicated message and found it missing.
So I don't think so at the moment, so should I make a proposal in Issue or write a copy myself?
© 2022 OneMinuteCode. All rights reserved.