From c01140f73a0e555378199fe9348e72350bb0d4d5 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 24 Mar 2024 23:46:15 +0100 Subject: [PATCH] Set the correct phpcs runtime options for plugins 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. --- remote_branch_checker/remote_branch_checker.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/remote_branch_checker/remote_branch_checker.sh b/remote_branch_checker/remote_branch_checker.sh index 1467d15c..953c113d 100755 --- a/remote_branch_checker/remote_branch_checker.sh +++ b/remote_branch_checker/remote_branch_checker.sh @@ -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}