Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created September 17, 2018 18:34
Show Gist options
  • Save garybernhardt/c2fceef67bcba989b2742dad88c9170b to your computer and use it in GitHub Desktop.
Save garybernhardt/c2fceef67bcba989b2742dad88c9170b to your computer and use it in GitHub Desktop.
Automatically fix rubocop errors, with one commit per error
rubocop | egrep ' (W|C): ' | cut -d ' ' -f 3 | sort -u | sed 's/:$//' | while read cop; do
git checkout .
rubocop -a --only "$cop";
if [[ $(git diff --stat) != '' ]]; then
git add --all
git commit -m "fix rubocop cop $cop"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment