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

Don't load configuration files outside of the current project unless there's no project specific configuration #8314

Merged

Commits on Jul 13, 2020

  1. Fix traverse_files_upwards to make searching up to the root possible

    Previously, the meaning of `FileFinder.root_level` would be "first non
    searched directory", now it is "last searched directory".
    
    This is more intuitive in my opinion (I assumed this behavior from the
    beginning until I found out it was not like that), but also more
    "correct", because it allows you to search up to the root directory if
    `FileFinder.root_level` is set to "/".
    
    Note that this `FileFinder.root_level?` logic is only useful for testing to
    provide an isolated environment not affected by the external file system
    where the tests are running. When rubocop runs "normally", it's ignored.
    
    However, in follow up work, I plan to start using these code paths, and
    this change allows me to stop artificially passing the parent of the
    directory where I want to stop searching.
    deivid-rodriguez committed Jul 13, 2020
    Copy the full SHA
    1aab1a6 View commit details
    Browse the repository at this point in the history
  2. Only look up to the project's root for exclusions

    If there's a specific project configuration, we don't want to pick up
    the exclusions in the user configuration. This doesn't happen already in
    the case of XDG setups, or if the HOME directory is not a parent of the
    project root directory. The specs currently configure such a setup, even
    if not very common in real life, maybe to workaround this issue.
    
    This PR fixes the problem by defining the root of project as the highest
    folder up in the directory hierarchy that contains a `Gemfile` or
    `gems.rb` file. Even if this definition matches most ruby projects, we
    could add additional fallbacks (like a `.gemspec` file?) to include more
    edge cases.
    deivid-rodriguez committed Jul 13, 2020
    Copy the full SHA
    f0adb9f View commit details
    Browse the repository at this point in the history
  3. Ignore configuration files outside of the project

    If by any chance, one happens to leave a `.rubocop.yml` file outside of
    my project, ignore it.
    deivid-rodriguez committed Jul 13, 2020
    Copy the full SHA
    12d80e5 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    469ca61 View commit details
    Browse the repository at this point in the history