rubocop on VScode not working.Error “rubocop is not executable”

The accepted answer didn’t work for me. However, I did find a comment by jdarnok on this GitHub issue that worked for me. First, to get the user’s path of the program file, I ran: rbenv which rubocop which gave me this result: /Users/<your username>/.rbenv/versions/2.6.2/gemsets/Rails4.2_EnergyLink/bin/rubocop Then I ran: which rubocop which gave me this result: … Read more

Rubocop, how to Disable/Enable cops on blocks of code

I answer my question because it is always very difficult for me to find the reference to this solution: # rubocop:disable Metrics/MethodLength def my_code .. end # rubocop:enable Metrics/MethodLength Same for multiple cops: # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def my_code .. end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength Documentation: https://docs.rubocop.org/rubocop/configuration.html#disabling-cops-within-source-code

Why does RuboCop suggest replacing .times.map with Array.new?

The latter is more performant; here is an explanation: Pull request where this cop was added It checks for calls like this: 9.times.map { |i| f(i) } 9.times.collect(&foo) and suggests using this instead: Array.new(9) { |i| f(i) } Array.new(9, &foo) The new code has approximately the same size, but uses fewer method calls, consumes less … Read more