danger-rubocop
danger-rubocop copied to clipboard
Feature request: option to lint all files even if they are not changed in the PR
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 😁
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?
Hey! Yeah that makes sense, I think a readme addition sounds like a great idea!