There is no way to author a set of rules such that it can't be abused by someone with the power to enforce it. That's why the law has judges, juries, courts of appeal, standards of evidence, disclosure rules, corpus delicti, habeas corpus, and so on.
The problem is not the CoC, but the lack of accountability, oversight, and transparency in enforcement.