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

Feature request: option to lint all files even if they are not changed in the PR #43

Open
unikitty37 opened this issue Oct 28, 2020 · 2 comments

Comments

@unikitty37
Copy link
Collaborator

danger-rubocop can be called with a list of files to be linted, otherwise it defaults to linting only files changed in the PR. I use an AllCops: Include: section in my .rubocop.yml to specify which files in the project should be linted.

If I pass a list of files to lint, this works fine. However, there is no way to tell it to lint all files in the project, even if they weren't changed in the PR.

Currently, fetch_files_to_lint does this:

      to_lint = (files ? Dir.glob(files) : (git.modified_files + git.added_files))

The problem with this is when the .rubocop.yml changes — if a cop that was previously disabled is now enabled, or a RuboCop upgrade adds a new cop, then danger-rubocop will ignore any violations if the file containing the violation was not changed as part of the PR.

Would it be possible to have a lint_unchanged_files option (defaulting to off, for compatibility) that would simply just use whatever include/exclude behaviour is specified in the RuboCop config — the equivalent of just running rubocop with no file list?

At least in my case, the extra time taken on a CI run is negligible, and certainly less than the time taken to unearth and fix these offences when they finally come to light 😁

@unikitty37
Copy link
Collaborator Author

Actually, it looks like passing files: '' will do the trick, as empty strings are truthy — that will glob to an empty array, causing rubocop to be called with no file list, which will then just pick up the files from .rubocop.yml, just like typing bundle exec rubocop does.

Is it worth mentioning this in the README, do you think?

@ashfurrow
Copy link
Owner

Hey! Yeah that makes sense, I think a readme addition sounds like a great idea!

unikitty37 added a commit to unikitty37/danger-rubocop that referenced this issue Oct 29, 2020
Document the following cases:

* `files` option not specified (lint only changed files)
* `files` option is empty string (lint all files)

See ashfurrow#43.
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

No branches or pull requests

2 participants