I think this snippet needs some context. In all contexts that I can imagine, the first line should actually be
if which jq &>/dev/null; then
brew install jq
fi if which jq &>/dev/null; then
brew install jq
fi