Back up a step.
If there are entire answers that just fix tangential problems in the asker's code without addressing the question that was asked, then there's something significantly wrong with the question to begin with. Trivially, it's a problem that the code has errors that are tangential to the one being asked about. More profoundly, it's a problem that the code is long enough to contain several such errors. Askers are supposed to provide minimal code examples; we have a closure reason for those that don't:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.
(emphasis mine).
If we reframe the primary problem as being with the question, the remedy for this sort of situation becomes clearer: either fix the question by editing, or nuke it. (The latter can be helped along, depending upon your rep level, with your downvotes, close flags/votes, and delete votes.)
When editing, some guidelines I'd suggest following:
- Try to reduce the code to the minimal form needed for the question to make sense
- If there's also waffly prose, try to tighten that up, too
- Don't leave existing answers invalidated, but don't be afraid to invalidate existing comments-posted-as-answers. If somebody has posted a load of irrelevant commentary about the asker's variable name typos as an "answer", you're not obligated to keep those typos around in the question forever. That answer should just be downvoted and deleted.
- ... but do leave a comment on such answers explaining what you've done, as a courtesy
- If some existing answers both address the core question being asked and irrelevant errors in the code, fix the errors in the question and eliminate the references to them from the answers (explaining why in your edit summary)
- If some existing answers include modified versions of the entire code block the asker posted, apply your tidying-up edits to both the code in the question and the code in every answer. Take particular care here to preserve the meaning of the answer and not to introduce errors into any party's code.
Ideally answerers would tidy up wall-of-code questions before answering them and we'd never find ourselves having to do these kinds of sweeping cleanups. But since they don't, it falls to us to polish the posts we end up with as best we can.