Skip to content

Commit

Permalink
Set the correct phpcs runtime options for plugins
Browse files Browse the repository at this point in the history
Until now we were completely excluding some sniffs to
avoid them to be run.

While that's correct, better if we use the config
options created for that.

Note that, because we have to pass empty ('') strings
we need to handle all the arguments as an array,
so shell doesn't do strange things and the binary
being called do receive everything (empty strings included)
as proper arguments.

Trying to pass the information as a string doesn't work ok
when handling empty strings.
  • Loading branch information
stronk7 committed Mar 24, 2024
1 parent 0596a5f commit c01140f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions remote_branch_checker/remote_branch_checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,18 @@ rm ${WORKSPACE}/check_upgrade_savepoints.php
# If we are checking a plugin, there are some differences in the checks performed.
# TODO: If https://github.com/moodlehq/moodle-cs/issues/92 becomes implemented, then
# we'll just have to change to the new, plugins specific, standard and forget.
phpcs_isplugin=""
declare -a phpcs_isplugin=()
if [[ -n "${isplugin}" ]]; then
# We exclude some Sniffs that are not applicable to plugins.
phpcs_isplugin="--exclude=moodle.Commenting.TodoComment"
# Here we can exclude some checks or set runtime config values for the plugin checks.
phpcs_isplugin=(
"--runtime-set" "moodleTodoCommentRegex" ""
"--runtime-set" "moodleLicenseRegex" ""
)
fi
echo "Info: Running phpcs..."
${phpcmd} ${mydir}/../vendor/bin/phpcs \
--runtime-set moodleComponentsListPath "${WORKSPACE}/work/valid_components.txt" \
${phpcs_isplugin} \
"${phpcs_isplugin[@]}" \
--report=checkstyle --report-file="${WORKSPACE}/work/cs.xml" \
--extensions=php --standard=moodle ${WORKSPACE}

Expand Down

0 comments on commit c01140f

Please sign in to comment.