-
-
Notifications
You must be signed in to change notification settings - Fork 282
Description
We’ve encountered a situation where Rails/Output
and Rails/Exit
behave differently depending on the environment in which RuboCop is run.
Specifically, some files are linted in certain environments but not in others, even though the project content is the same.
Expected behavior
I think that Include
and Exclude
path patterns for cops like Rails/Output
and Rails/Exit
should be evaluated relative to the directory where the .rubocop.yml
file resides. This would ensure consistent linting results regardless of the absolute location of the project on the filesystem or the environment where RuboCop is run.
Actual behavior
When running RuboCop in different environments where the project is mounted or checked out in different absolute paths (e.g., /app
inside Docker vs. ~/Projects/myapp
on macOS), the Include
patterns such as **/app/**/*.rb
seem to match different files. As a result, cops like Rails/Output
or Rails/Exit
detect offenses in some environments but not others, causing inconsistent linting results.
ref:
default.yml - Rails/Exit > Include
default.yml - Rails/Output > Include
Steps to reproduce the problem
- Place a file with puts or exit in bin/ or another directory inside your project.
- Run RuboCop on two environments with different project root paths, e.g.:
- ~/Projects/app
- ~/Projects/myapp
- Observe that the file in bin/ is flagged in app but not myapp
Small example is: https://github.com/mizoR/rubocop-rails-1487
RuboCop version
$ bundle exec rubocop -V rbenv:3.4.4
1.75.8 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.44.1, analyzing as Ruby 3.4, running on ruby 3.4.4) [arm64-darwin24]
- rubocop-rails 2.32.0