Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing tools/config for PHPCS #77

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,36 @@ VIOLATIONS=0
# Check backend
STANDARD="Drupal"
BIN="./vendor/bin"
DDEV="/usr/bin/ddev"

# Respect the configuration file included in the repo, if it exists.
if [ -f phpcs.xml ]; then
STANDARD="phpcs.xml"
fi

echo
echo "Drupal Coder pre-commit hook – commit with the --no-verify option to skip the hook"
echo

# Check whether PHP_CodeSniffer can be found
if [ ! -f "$BIN/phpcs" ]
then
echo "Drupal Coder not found – is it installed? 'composer require drupal/coder'"
echo
exit 1
if [ -f "$BIN/phpcs" ]; then

# Run the check in ddev, if this is a ddev site.
if [ -d .ddev ] && [ -x $DDEV ]; then
PHPCS="$DDEV exec phpcs"
else
PHPCS="$BIN/phpcs"
fi

else
echo "Drupal Coder not found – is it installed?"
fi

# Run the sniffer
echo "Running Drupal Coder."
echo "Running Drupal Coder: ${PHPCS}"
echo
PHPCS=("$BIN/phpcs" "--standard=$STANDARD" "--filter=gitstaged" "--encoding=utf-8" "-p" ".")
"${PHPCS[@]}"
OUTPUT=(${PHPCS} --standard=${STANDARD} --filter=GitStaged --encoding=utf-8 -p .)
"${OUTPUT[@]}"
VIOLATIONS=$((VIOLATIONS + $?))

# Check frontend
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"cweagans/composer-patches": "^1.7",
"drupal/better_exposed_filters": "^7.0",
"drupal/cer": "^5.0@beta",
"drupal/coder": "^8.3",
"drupal/core-composer-scaffold": "^10.3",
"drupal/core-project-message": "^10.3",
"drupal/core-recommended": "^10.3",
Expand Down
Loading