Skip to content

RuboCop: Ignore parent exclusions when RuboCop is run within gems/

Peter Leitzen requested to merge pl-gems-rubocop-ignore-parent-exclusions into master

What does this MR do and why?

With this MR, we no longer need to run rubocop with --config .rubocop.yml in monorepo or gem directory.

Now, running rubocop in both monorepo and gems/ directories behaves as expected:

  1. In monorepo, inspecting files with --force-exclusion from gems/ is a no-op
  2. In gems/, inspect files works without passing --config .rubocop.yml

Please see #417281 (closed) for much context and further investigation.

How to set up and validate locally

$ cd gitlab # monorepo
$ bundle exec rubocop --force-exclusion gems/gitlab-utils/lib/gitlab/utils/strong_memoize.rb
Inspecting 0 files


0 files inspected, no offenses detected

$ for i in $(ls gems/*/.rubocop.yml); do (cd $(dirname $i) && pwd && bundle --quiet && bundle exec rubocop
); done
/home/peter/devel/gitlab/gdk/gitlab/gems/activerecord-gitlab
Inspecting 8 files
........

8 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/click_house-client
Inspecting 0 files


0 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/gitlab-rspec
Inspecting 9 files
.........

9 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/gitlab-schema-validation
Inspecting 66 files
..................................................................

66 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/gitlab-utils
Inspecting 12 files
............

12 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/ipynbdiff
Inspecting 15 files
...............

15 files inspected, no offenses detected
/home/peter/devel/gitlab/gdk/gitlab/gems/rspec_flaky
Inspecting 17 files
.................

17 files inspected, no offenses detected

📓 RuboCop fails to inspect files in gems/click_house-client. This is addressed in !126183 (comment 1467108888).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports