Skip to content

Fix crash when running rubocop -d on a config with a remote inherit_from that causes a duplicate setting warning #13608

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

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Dec 19, 2024

When you use inherit_from with a remote config, and that config inherits itself, it's possible a overridden config warning would be triggered. However, PathUtil#smart_path does not expect a RemoteConfig, and thus was crashing.

undefined method `start_with?' for an instance of RuboCop::RemoteConfig
/src/rubocop/lib/rubocop/path_util.rb:42:in `smart_path'
/src/rubocop/lib/rubocop/config_loader_resolver.rb:178:in `duplicate_setting_warning'
/src/rubocop/lib/rubocop/config_loader_resolver.rb:174:in `warn_on_duplicate_setting'

I made two changes:

  1. PathUtil#smart_path will no longer crash when given a RemoteConfig
  2. The warning is no longer shown when looking at remote inheritence, because these files are not changable within the project. We already do the inverse when a local configuration is overridden remotely.

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…t_from` that causes a duplicate setting warning
@koic koic merged commit b769939 into rubocop:master Dec 24, 2024
22 checks passed
@koic
Copy link
Member

koic commented Dec 24, 2024

Good catch! Thanks!

@dvandersluis dvandersluis deleted the fix/remote-inherit-debug branch December 24, 2024 03:05
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 this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy