Skip to content

Commit

Permalink
[Fix rubocop#10871] Restore RuboCop::ConfigLoader.project_root as d…
Browse files Browse the repository at this point in the history
…eprecated

Fixes rubocop#10871 and utkarsh2102/rubocop-packaging#44.

This PR restores `RuboCop::ConfigLoader.project_root` as deprecated.

It fixes the following build error.

```console
% cd path/to/github.com/utkarsh2102/rubocop-packaging
% bundle update && bundle exec rake
(snip)

Failures:

  1) RuboCop::Cop::Packaging::BundlerSetupInTests when `require
  bundler/setup` is used in a Rakefile does not register an offense
     Failure/Error: let(:project_root) {
  RuboCop::ConfigLoader.project_root }

     NoMethodError:
       undefined method `project_root' for RuboCop::ConfigLoader:Class
     # ./spec/rubocop/cop/packaging/bundler_setup_in_tests_spec.rb:6:in
       `block (2 levels) in <top (required)>'
     # ./spec/rubocop/cop/packaging/bundler_setup_in_tests_spec.rb:39:in
       `block (3 levels) in <top (required)>'
     # ./spec/rubocop/cop/packaging/bundler_setup_in_tests_spec.rb:43:in
       `block (3 levels) in <top (required)>'
```

I considered a soft deprecation, but decided to issue a warning as it
is probably of limited use.
  • Loading branch information
koic committed Aug 5, 2022
1 parent 7593ec8 commit 6c20212
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
@@ -0,0 +1 @@
* [#10871](https://github.com/rubocop/rubocop/issues/10871): Restore `RuboCop::ConfigLoader.project_root` as deprecated. ([@koic][])
12 changes: 12 additions & 0 deletions lib/rubocop/config_loader.rb
Expand Up @@ -137,6 +137,18 @@ def default_configuration
end
end

# Returns the path RuboCop inferred as the root of the project. No file
# searches will go past this directory.
# @deprecated Use `RuboCop::ConfigFinder.project_root` instead.
def project_root
warn Rainbow(<<~WARNING).yellow
`RuboCop::ConfigLoader.project_root` is deprecated and will be removed in RuboCop 2.0. \
Use `RuboCop::ConfigFinder.project_root` instead.
WARNING

ConfigFinder.project_root
end

PENDING_BANNER = <<~BANNER
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
Expand Down

0 comments on commit 6c20212

Please sign in to comment.