Links between gangs and cops laid bare in judgment