If you ask me, the answer is no and I will try to explain why.
Code has special "stance" in my opinion:
- It's not bound to readability or grammar rules like ordinary post contents.
- One small change in code might cause huge impact and render the whole post useless.
- It's under the responsibility of the post author, and his/her alone. If there is mistake in code, nobody should correct that for the author - he or she should do that themselves.
Posting more code than necessary is borderline case - on one hand, it's not wrong code but on the other hand you can't always be 100% sure what is the real relevant part. Maybe the author forgot to mention something in the post, and the code explains this?
And "when there is doubt, there is no doubt" - better play it safe.
Just post comment on the post asking the author to put only the relevant code - that's the best course of action in my opinion.