Unfortunately it doesn't work if you forbid unbound variables with set -u. Like this (as suggested in the Unofficial strict mode article: https://news.ycombinator.com/item?id=8054440):
$cat z
#!/bin/bash
set -u # fail if unset variable is used
if [[ -n ${COLODEBUG} && ${-} != *x* ]]
then
:() {
[[ ${1:--} != ::* ]] && return 0
printf '%s\n' "${*}" >&2
}
fi
echo hello
$./z
./z: line 10: COLODEBUG: unbound variable
$
The -n test should look like this: if [[ -n ${COLODEBUG:-} && ${-} != *x* ]]