Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlinks pointing to excluded directories are not excluded #9636

Closed
ob-stripe opened this issue Mar 24, 2021 · 0 comments · Fixed by #9703
Closed

Symlinks pointing to excluded directories are not excluded #9636

ob-stripe opened this issue Mar 24, 2021 · 0 comments · Fixed by #9703

Comments

@ob-stripe
Copy link
Contributor

ob-stripe commented Mar 24, 2021

After upgrading to Rubocop 0.93.0 or a more recent version, symbolic links pointing to directories that are excluded in .rubocop.yml are no longer excluded.

The behavior change was introduced by this PR: #8815

I'm not sure whether you'd consider this a bug, but it's definitely a behavior change that caught us off guard while trying to upgrade Rubocop to a more recent version.

Expected behavior

With Rubocop 0.92.0 or older versions, symbolic links pointing to directories that are excluded in .rubocop.yml were themselves excluded.

E.g. with the following file tree:

$ ls -lR .
total 16
-rw-r--r--   1 ob  staff  109 Mar 23 22:34 .rubocop.yml
-rw-r--r--  1 ob  staff  172 Mar 23 22:29 Gemfile
-rw-r--r--  1 ob  staff  631 Mar 23 22:29 Gemfile.lock
drwxr-xr-x  3 ob  staff   96 Mar 23 22:21 build
drwxr-xr-x  3 ob  staff   96 Mar 23 22:26 foo

./build:
total 0
drwxr-xr-x  3 ob  staff  96 Mar 23 22:24 protoc_out

./build/protoc_out:
total 8
-rw-r--r--  1 ob  staff  764 Mar 23 22:22 ping_pb.rb

./foo:
total 0
lrwxr-xr-x  1 ob  staff  19 Mar 23 22:26 protoc_out -> ../build/protoc_out

and a .rubocop.yml as follows:

AllCops:
  TargetRubyVersion: 2.7
  Exclude:
    - build/protoc_out/**/*

then the contents fo foo/protoc_out were excluded, because the link resolves to build/protoc_out which is itself excluded:

$ bundle exec rubocop -V
0.92.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)
$ bundle exec rubocop --list-target-files --debug
For /Users/ob/workspace/ruby/rubocop-test-link: configuration from /Users/ob/workspace/ruby/rubocop-test-link/.rubocop.yml
Default configuration from /Users/ob/workspace/ruby/rubocop-test-link/vendor/bundle/ruby/2.7.0/gems/rubocop-0.92.0/config/default.yml
Gemfile
Finished in 0.08337699994444847 seconds

Actual behavior

With Rubocop 0.93.0 or more recent, symbolic links pointing to directories that are excluded in .rubocop.yml are no longer excluded:

$ bundle exec rubocop -V
0.93.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)
$ bundle exec rubocop --list-target-files --debug
For /Users/ob/workspace/ruby/rubocop-test-link: configuration from /Users/ob/workspace/ruby/rubocop-test-link/.rubocop.yml
Default configuration from /Users/ob/workspace/ruby/rubocop-test-link/vendor/bundle/ruby/2.7.0/gems/rubocop-0.93.0/config/default.yml
Gemfile
foo/protoc_out/ping_pb.rb
Finished in 0.08175699971616268 seconds

Steps to reproduce the problem

Set up a file structure as above, and run Rubocop 0.93.0 or more recent.

RuboCop version

$ bundle exec rubocop -V
0.93.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.2 x86_64-darwin19)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant