Skip to content

Commit

Permalink
Merge pull request #2 from baelter/rubocop-args
Browse files Browse the repository at this point in the history
Allow passing arguments to rubocop
  • Loading branch information
dbackeus authored Nov 4, 2023
2 parents f90902d + 34ee430 commit 1d2ee65
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ Specifying `gem_versions` in the standard `gem install` format.
with:
gem_versions: rubocop:1.18.3 rubocop-rspec:2.0.0 rubocop-<some-other-plugin>:1.2.0
```

#### rubocop arguments

Allows you to pass additional arguments to rubocop. E.g.

```yaml
- uses: reclaim-the-stack/rubocop-action@v1
with:
rubocop_arguments: --config .rubocop.yml
```
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ inputs:
gem_versions:
description: Gem versions to install
default: rubocop:1.54.1 rubocop-rails:2.20.2 rubocop-rspec:2.22.0
rubocop_arguments:
description: Arguments passed to rubocop cli
default: ""
runs:
using: composite
steps:
- run: ruby $GITHUB_ACTION_PATH/rubocop.rb
- run: ruby $GITHUB_ACTION_PATH/rubocop.rb ${{ inputs.rubocop_arguments }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# JSON reference: https://docs.rubocop.org/rubocop/formatters.html#json-formatter
files_with_offenses =
if changed_ruby_files.any?
command = "rubocop #{changed_ruby_files.map(&:path).join(' ')} --format json --force-exclusion"
command = "rubocop #{changed_ruby_files.map(&:path).join(' ')} --format json --force-exclusion #{ARGV.join(' ')}"

puts "Running rubocop with: #{command}"
JSON.parse(`#{command}`).fetch("files")
Expand Down

0 comments on commit 1d2ee65

Please sign in to comment.