Possible Duplicate:
How far can I refactor someone else's code?

I see a lot of edits in queue where some well-meaning user attempts to fix OP's code. They range from minor syntax corrections, to near total rewrites.

When is it appropriate to accept or reject these edits?

Here are my thoughts:

On questions:

  • Never edit OP's code no matter how wrong it is, unless it is strictly to increase readability, and doesn't change how the code actually works. The very question itself might be solved by pointing out the error that you are fixing, no matter how small, so don't remove or correct it in the original post.

On answers:

  • Only edit code for obvious typos or mistakes by the author, do not attempt to "improve" the author's code. Even if the author is suggesting something stupid or dangerous, like forgetting to escape data for a database INSERT, it's better to leave a comment and let the author correct it. Downvote if applicable.

Editing the non-code parts of a post for grammar and the like are usually not going to change what the author intended to say very much, but code is taken literally, even a very minor edit will make a huge difference.

Am I close to the mark, or way off? Is there anything else to take into consideration? What are the exceptions, if any? I'm seeing a ton of these in the suggested edit queue.

When is it appropriate to edit someone else's code, and how should we deal with these suggestions from other users?

In addition (maybe a separate question), what can I do to help educate users who suggest unwelcome edits in general? Is there any way to leave them a comment so they can understand why the edit was rejected, so they don't continue to suggest more edits of a similar nature?*

* An @ comment will notify the editor, this is clearly documented here: How do comment @replies work? *

* However, it's not clear if @ replies ping the author of a rejected edit...


1 Answer 1


On questions, it really should only be done to increase readability, like spacing and tabs. I edited on the other day just for that, and still ended up deleting a errant apostrophe that may have been the OP's problem, so you have to be careful.

On answers, I may improve something really obvious that is either a mistake, or just looked like it was overlooked.

  • The first thing you said is exactly what I'm talking about. For instance, OP has a question about why his CSS isn't working. Another user comes along and fixes the closing HTML tag of one of OP's links or table or whatever (which could be the very issue, or at least related to it). Assuming no visible confirmation from OP that is was indeed a mistake, do I roll back the edit?
    – user159834
    Commented Aug 9, 2011 at 22:45
  • @Wesley, yes, I'd leave in the good formatting and put the exact error back in (and then point it out to the OP). Commented Aug 9, 2011 at 22:47
  • @Wesley I would also offer the first editor the chance (through a comment) to formulate it as an answer, if this is applicable. Despite it being fairly obvious, some new users may not make this connection.
    – jonsca
    Commented Aug 9, 2011 at 22:53
  • Well, it's not always the answer but it is often related to the problem. Are editors even notified in comments? (I added something regarding this to the end of my question, just now)
    – user159834
    Commented Aug 9, 2011 at 22:59
  • @Wesley: If people refer to them (using @ syntax), apparently so. Never noticed it myself, but then I always try to edit to produce the thing that the original author wanted to say but didn't for some reason. Commented Aug 9, 2011 at 23:25
  • @Donal, yes you are correct about pinging the editor - I was entirely unaware: meta.stackexchange.com/questions/36052/…
    – user159834
    Commented Aug 9, 2011 at 23:31
  • ...however, it just dawned on me that authors of rejected edits are not technically editors, so they do not seem to be eligible for an @ comment.
    – user159834
    Commented Sep 23, 2011 at 18:59
  • I'm not at all sure what the advantage is of allowing anyone to edit a question, even if it's just reformatting. It smacks of a level of hubris that shouldn't be in any Q&A session, whether it's here or in a classroom, unless it's part of the answer itself. Commented Nov 29, 2014 at 18:00