Upon motion directed to an answer or reply, substantial defects in all prior pleadings may be considered and judgment rendered against the party who has first failed to state a claim upon which relief can be granted or to state a legal defense to a claim.
§ 509.350, RSMo