You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I was looking forward to removing the TargetRubyVersion from my config with the 0.41 release so that it could just use the existing declaration in my .ruby-version file, however I've had a problem since doing so. Although everything worked fine when using RuboCop from the command line I was getting syntax errors (when my files had keyword arguments) with the linter-rubocop plugin for Atom.
I've now realised the problem is because linter-rubocop executes rubocop from in the directory of the file you're running it on, and when doing so it's not picking up the .ruby-version file as it should. I can now replicate this behaviour from the console, like so:
$ rubocop app/models/user.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
$ cd app/models
$ rubocop user.rb
Inspecting 1 file
E
Offenses:
user.rb:1:1: E: class definition in method body
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
class User < ActiveRecord::Base
^^^^^
user.rb:31:23: E: unexpected token tRPAREN
(Using Ruby 2.0 parser; configure using TargetRubyVersion parameter, under AllCops)
def self.something(name:)
^
1 file inspected, 2 offenses detected
I think the solution should be that RuboCop looks for the .ruby-version file in more than the current directory. If we don't want it to check every parent directory (like I would assume it does for the config file) then the minimum it should do is look in the same directory that it finds the config file in.
I think the solution should be that RuboCop looks for the .ruby-version file in more than the current directory. If we don't want it to check every parent directory (like I would assume it does for the config file) then the minimum it should do is look in the same directory that it finds the config file in.
Hey! I was looking forward to removing the
TargetRubyVersion
from my config with the0.41
release so that it could just use the existing declaration in my.ruby-version
file, however I've had a problem since doing so. Although everything worked fine when using RuboCop from the command line I was getting syntax errors (when my files had keyword arguments) with thelinter-rubocop
plugin for Atom.I've now realised the problem is because
linter-rubocop
executesrubocop
from in the directory of the file you're running it on, and when doing so it's not picking up the.ruby-version
file as it should. I can now replicate this behaviour from the console, like so:I think the solution should be that RuboCop looks for the
.ruby-version
file in more than the current directory. If we don't want it to check every parent directory (like I would assume it does for the config file) then the minimum it should do is look in the same directory that it finds the config file in.RuboCop version
The issue applies from
v0.41.0
all the way tomaster (cd7246f)
.The text was updated successfully, but these errors were encountered: