Skip to content

RuboCop: Use absolute path for cache root directory

Peter Leitzen requested to merge pl-rubocop-absolute-cache-root-dir into master

What does this MR do?

Use absolute path for RuboCop's cache root directory.

This avoids the creation of orphan directories when workspace root is changed. For example: VSCode Ruby plugin.

Using Dir.getwd is safe because RuboCop is using Dir.chdir right before reading the configuration files to get the proper directory context.

Both Using __dir__ ( .) and __FILE__ ( (erb)) won't work.

Refs !64321 (comment 651140854) gitlab-foss!28672 (merged) https://github.com/rubyide/vscode-ruby/issues/594

Screenshots or Screencasts (strongly suggested)

n/a

How to setup and validate locally (strongly suggested)

Before

  1. cd app/models
  2. bundle exec rubocop wiki.rb
  3. ls -al tmp/rubocop_cache directory created 👀

After

  1. cd app/models
  2. bundle exec rubocop wiki.rb
  3. ls -al tmp/rubocop_cache nothing created 🎉

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen

Merge request reports