Skip to content

Instantly share code, notes, and snippets.

@ekohl
Created December 29, 2022 12:42
Show Gist options
  • Save ekohl/b41006003553dce67b9c551f306f8080 to your computer and use it in GitHub Desktop.
Save ekohl/b41006003553dce67b9c551f306f8080 to your computer and use it in GitHub Desktop.
A script to fix things in rubocop_todo.yml
#!/bin/bash
set -e
set -x
bundle exec rubocop --auto-gen-config --no-auto-gen-timestamp --no-offense-counts
TODO=$(~/.local/bin/yq -r '. | keys[]' .rubocop_todo.yml | grep -vE 'Layout/LineLength|Lint/UriEscapeUnescape|Naming/MethodParameterName|Layout/DefEndAlignment|Layout/IndentationConsistency')
echo > .rubocop_todo.yml
if [[ -n "$(git status --porcelain)" ]] ; then
git commit -m '[TMP] clean Rubocop TODO' .rubocop_todo.yml
fi
for COP in $TODO ; do
bundle exec rubocop --auto-correct-all --only $COP
if [[ -n "$(git status --porcelain)" ]] ; then
git commit -am "Fix Rubocop $COP"
fi
done
bundle exec rubocop --auto-gen-config --no-auto-gen-timestamp --no-offense-counts
git commit -m 'Regenerate Rubocop TODO' .rubocop_todo.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment