Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 2c9b7d9

Browse files
author
Derik Evangelista
committed
Update pre-commit hook to use bundled rubocop
Latest rubocop versions deprecated some rules that are currently being used
1 parent 1fc22bf commit 2c9b7d9

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

scripts/rubocop-pre-commit

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ CLEAR_LINE='\r\033[K'
99

1010
REPO_BASE_DIR="$(git rev-parse --show-toplevel)"
1111

12-
if ! command -v rubocop > /dev/null; then
13-
printf "${CLEAR_LINE}💀${RED} Install Rubocop and be sure it is available on your PATH.${NO_COLOR}\n"
14-
printf "ℹ️ Try 'gem install rubocop'\n"
15-
exit 1
16-
fi
17-
1812
pushd "${REPO_BASE_DIR}"
1913
INNOCENTS="$(git diff --name-only --diff-filter=AMC | grep -i '.*\.rb' | sort)"
2014
SUSPECTS="$(git diff --cached --name-only --diff-filter=AMC | grep -i '.*\.rb' | sort)"
@@ -24,14 +18,14 @@ pushd "${REPO_BASE_DIR}"
2418

2519
printf "\n🚔 Linting with Rubocop...\n"
2620

27-
if rubocop --parallel --cache=true --format autogenconf ${SUSPECTS}; then
21+
if bundle exec rubocop --parallel --cache=true --format autogenconf ${SUSPECTS}; then
2822
printf "${CLEAR_LINE}🎉${GREEN} Rubocop is appeased.${NO_COLOR}\n"
2923
exit 0
3024
fi
3125

3226
printf "\n${CLEAR_LINE}${RED}💀 Rubocop found some issues. Let's see if it can autocorrect the files you're trying to commit...${NO_COLOR}\n"
3327

34-
if ! rubocop --auto-correct --cache=true ${SUSPECTS}; then
28+
if ! bundle exec rubocop --auto-correct --cache=true ${SUSPECTS}; then
3529
printf "\n${CLEAR_LINE}${RED}💀 Rubocop couldn't autocorrect everything! 😭 ${NO_COLOR}\n"
3630
exit 1
3731
fi

0 commit comments

Comments
 (0)