#!/usr/bin/env bash
# Code linting for SaaS project.
set -e

APP_DIR=${APP_DIR:-/app}
PROFILE_DIR=${PROFILE_DIR:-${APP_DIR}/web}

# Lint code.
${APP_DIR}/tests/vendor/bin/parallel-lint --exclude /app/tests/vendor --exclude ${PROFILE_DIR}/themes/custom/*/node_modules -e php,inc,module,theme,install,profile,test ${PROFILE_DIR}/themes/custom

# Check code standards.
${APP_DIR}/tests/vendor/bin/phpcs --standard=${APP_DIR}/tests/phpcs.xml ${PROFILE_DIR}/themes/custom

# Check code mess.
${APP_DIR}/tests/vendor/bin/phpmd ${PROFILE_DIR}/themes/custom text codesize,unusedcode,cleancode
