(a) Dismissing an information. In its discretion, for substantial cause and in furtherance of justice, the court may, either on its own initiative or upon application of either party, order an information or indictment dismissed.
(b) Mandatory dismissal. The court shall dismiss the information or indictment when:
(b)(1) There is unreasonable or unconstitutional delay in bringing defendant to trial;
(b)(2) The allegations of the information or indictment, together with any bill of particulars furnished in support thereof, do not constitute the offense intended to be charged in the pleading so filed;
(b)(3) It appears that there was a substantial and prejudicial defect in the impaneling or in the proceedings relating to the grand jury;
(b)(4) The court is without jurisdiction; or
(b)(5) The prosecution is barred by the statute of limitations.
(c) Record of dismissal.The reasons for any such dismissal shall be set forth in an order and entered in the minutes.
(d) Effects of dismissal.If the dismissal is based upon the grounds that there was unreasonable delay, or the court is without jurisdiction, or the offense was not properly alleged in the information or indictment, or there was a defect in the impaneling or of the proceedings relating to the grand jury, further prosecution for the offense shall not be barred and the court may make such orders with respect to the custody of the defendant pending the filing of new charges as the interest of justice may require. Otherwise the defendant shall be discharged and bail exonerated.
An order of dismissal based upon unconstitutional delay in bringing the defendant to trial or based upon the statute of limitations, shall be a bar to any other prosecution for the offense charged.
(e) Dismissal by compromise.In misdemeanor cases, upon motion of the prosecutor, the court may dismiss the case if it is compromised by the defendant and the injured party. The injured party shall first acknowledge the compromise before the court or in writing. The reasons for the order shall be set forth therein and entered in the minutes. The order shall be a bar to another prosecution for the same offense; provided however, that dismissal by compromise shall not be granted when the misdemeanor is committed by or upon a peace officer while in the performance of duties, or riotously, or with an intent to commit a felony.