I don’t think discipline demerits affect one’s scholastic standing.
For what it’s worth, McCain’s Wikipedia entry says this:
McCain came into conflict with higher-ranking personnel, he did not always obey the rules, and that contributed to a low class rank (894 of 899) despite a strong intelligence.