May another user fix broken code in a question to make it on-topic?

If we find that a question contains obviously broken code, our standard procedure is to close the question, sending the author back to the drawing board.

But is it acceptable for another user to edit the question to fix the code and nominate it for reopening?

Follow-up question: What if a user just did that? Should the edit be rolled back as invalid? We would normally reject such meddling with code blocks. On the other hand, it seems kind of mean to do that, especially since we're just waiting for the original author to make just those same fixes. But then again, allowing such third-party fixes leads to a very slippery slope.

This is the specific incident that led to this question, and the comment I left in response when rolling it back:

In Rev 2, you changed more than the title and the intent: you also fixed some mismatched parentheses. That would be an invalid edit (though a strong hint for LeDarkMemer).

Other than extremely minor edits, I think the answer has to be NO.

If I've got the capitalization wrong on a case sensitive variable/function/method/class name in one out of the 20 times I used it in the pasted source code, or if I missed a singular semicolon or parenthesis or closing brace in several, several lines of source code, this is a very minor edit that probably isn't worth the hassle of closing. Any good IDE would have noticed this and depending on the IDE, it may have autocorrected it or would at least be making the correct change recommendation.

But there should never be the slightest amount of guess work in these changes, and they should always be very minor.

We disallow and rollback edits to indentation, because that is a reviewable aspect of the code.

If the change is significant as changing a function call (in the example, we changed between .append and assignment, well now you're significantly changing the actual source code.

If the original code works, you need to post this change as an answer explain why one is better than the other--just like we require you to comment on why good indentation is good rather than allowing users to just fix it in the question. If the original code does not work, then we're probably applying a slight bit of guess work to make the code work, and we may have made a change in an edit that the original asker doesn't understand.

In answers we post, we generally feel the need to explain the changes we recommend so that the user understands why our recommendation is better than what he has. If a question's source code has been edited only by the original asker, it is fair enough (though not necessarily always true) to expect the original asker to understand why his code does what it does, and so our answers' explanations can be tailored to a user with that level of understand. If someone comes in behind the asker and changes the source code in the question, we can no longer make the assumption that the asker understands the source code in the question.

If the code does not work, the asker needs to fix it themselves or post the exact same source code as a question on StackOverflow.

For clarity, trivially minor edits that require no guess work, and arguably, also do not require reading the plain-English part of the question should be okay. These would be things like an obvious copy & paste that missed a few characters.

Anything more significant than this, anything that requires guess work or reading the plain-English part, anything that changes which function was called or which class was used, these are all things that should be rolled back and only be changed by the asker.

In the specific case offered as example in the question, I think the rollback was appropriate.

The rule should be no, these edits are not allowed. But exceptions should be made for trivially minor edits which require no guess-work.

• This answer contradicts itself. In one breath you talk about how it shouldn't be changed because that "minor edit" is reviewable and in the next you say it's ok to make that edit. – RubberDuck Aug 16 '14 at 13:57
• I'm trying to draw a distinction between code that is broken because of something like a simple single character typo that any decent IDE would either auto-fix or make the correct suggest change automatically and the type of code that is so far broken that an average IDE wouldn't be capable of discerning how to fix it. – nhgrif Aug 16 '14 at 14:02
• Why should there be a distinction? – RubberDuck Aug 16 '14 at 14:06
• Because it's extraordinarily silly to put a question on hold because when I copy&pasted over I missed the final closing brace. Or I missed the first letter so now the first line of my code is lass MyClass {... meanwhile it's good to put broken code on hold. Putting broken code on hold should be the rule, but trivially minor edits to fix the technically broken code should be the exception to that rule. – nhgrif Aug 16 '14 at 14:09
• In the specific case offered as a test case in this question, I think the edit is larger than trivially minor and the rollback was appropriate. – nhgrif Aug 16 '14 at 14:10
• Well said, and mostly agreed. I would just say, however, that if the fix is so trivial that it's not worth closing, then it's also trivial enough to leave it buggy and mention it in a comment or answer. Then, we maintain a never-touch-the-code rule, except when it is obvious that the OP had difficulty formatting the code as intended. – 200_success Aug 16 '14 at 14:54
• @nhgrif What about errors that are obviously not copy&paste errors, like incorrect capitalization. I think that those indicate that the OP never compiled their code, let alone tested it. And that's a requirement on CR ("To the best of my knowledge, does the code work?"). – svick Aug 16 '14 at 21:55

I think that when this happens, it stops being code the OP "owns or maintains", so we shouldn't allow this.

• Strongly agreed. – RubberDuck Aug 16 '14 at 12:52
• I think I disagree with this answer, though I'm not sure whether I think an edit should be allowed. However, you're suggesting that if a coworker came over and noticed the one missing parenthesis in my 250 lines of source code that was preventing compilation, now I'm no longer the owner/maintainer because my coworker noticed such a small change? How about a question that was only posted here after being fixed via SO? In most situations I am familiar with, code does not have a singular owner/maintainer. – nhgrif Aug 16 '14 at 13:01
• I agree that it (at least mostly) should not be allowed, but I think the owns or maintain aspect of it is the incorrect reason. – Simon Forsberg Aug 16 '14 at 15:15
• @nhgrif If your coworker fixes it in the repository, I'd say it's still your code. If he changes it only on his disk, then I think it's no longer your code. Code on CR is somewhere between the two, but I think more like the latter case, because it's not where you maintain your code. – svick Aug 16 '14 at 17:21