Updated as per Vidar from shellcheck.net.
Email received from Vidar:
Hi,

On line 53 in the script, getopt is used with -u:

 -u, --unquoted
     Do not quote  the  output.  Note  that  whitespace  and  special
     (shell-dependent)  characters can cause havoc in this mode (like
     they do with other getopt(1) implementations).

This havoc is basically what Shellcheck is warning about.

Unfortunately it's not simply a matter of quoting the variable, since the
underlying problem is the way getopt is used.

Instead of -u, you can use -s bash, and then eval instead of word split:

args=$(getopt -o hd:w:c:P: --long help,domain:,warning:,critical:,path: -s
bash -n "$PROGRAM" -- "$@")
...
eval "set -- $args"

This way, no havoc is caused, and no shellcheck errors are reported.

Regards,
Vidar