Skip to content

Instantly share code, notes, and snippets.

@asaaki
Created September 8, 2023 10:28
Show Gist options
  • Save asaaki/00943eac929a9e65d1ce4e29484032c1 to your computer and use it in GitHub Desktop.
Save asaaki/00943eac929a9e65d1ce4e29484032c1 to your computer and use it in GitHub Desktop.
[ruby] rubocop, but only check git staged files
#!/bin/sh
# time execution
time bin/rubocop -L --stderr $(git diff --name-only --cached | grep '\.rb')
# bare minimum
bin/rubocop $(git diff --name-only --cached | grep '\.rb')
# -L = list files (good to see which one got checked since we don't see the nested command's output
# --stderr = may or may not be useful to pipe output there
# @see <https://docs.rubocop.org/rubocop/usage/basic_usage.html#command-line-flags>
# add other flags as you see fit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment