2

I got this edit rejected: https://stackoverflow.com/review/suggested-edits/15945932

The original answer links to code from an external source and does not reproduce the code from there correctly. For this reason, the original answer does not compile.

In my edit, I reproduce the code correctly so that it can compile. I find myself going to my rejected edit to remember how was the correct code.

I do not agree that it should be posted as a comment since the original answer (in my opinion) is incorrect.

4
  • 1
    As a rule edits that change code are rejected and best left as a comment for the author to change.
    – Joe W
    Commented May 9, 2017 at 12:18
  • I would wait until you have sufficient privileges to make such edits. The reason being that when they go through the review a lot of reviewers will reject because code changes could be damaging and so will be rejected.
    – Bugs
    Commented May 9, 2017 at 12:19
  • 2
    Edits to answers to fix some errors is fine @JoeW meta.stackoverflow.com/q/260245/458741
    – Ben
    Commented May 9, 2017 at 12:25
  • 1
    Note that copying code from external source into the post has good chance of violating license under which code was posted. Commented May 9, 2017 at 16:23

2 Answers 2

5

When you change/edit code, you have to consider some implications:

  1. Maybe the way the code is posted IS the real problem and by changing it you obscure the problem.
  2. The questioner maybe using the same libraries that you use, but in a different way, either allowed or disallowed. Editing that may again obscure the problem, or conflict with the initial intentions of the author.
  3. In case of an answer, It may be malformed but that will render it a bad answer. You can comment on that and the author can edit it as he thinks suitable.

In your specific case, if you read just above the authors code, he states that he only pasted the relevant (in his opinion) code from a link that he provided in his answer.


As a (strictly) personal rule of thumb, I touch on code only to make it more readable (code posted as one line, code block between ` and not in an actual block etc.). I do not even mess with indentation most of the time, because in languages like Python, that matters as well.

It is better to comment on the intentions of an author when you spot potentially malformed code.

4
  • The question specifies that this was an answer, not a question.
    – Ben
    Commented May 9, 2017 at 12:25
  • @Ben Ooops... I made my answer more general :) Commented May 9, 2017 at 12:30
  • In that case how do you square your answer with the FAQ: meta.stackoverflow.com/q/260245/458741?
    – Ben
    Commented May 9, 2017 at 12:32
  • @Ben By the use of "(strictly) personal rule of thump" which means that this approach is not canon, but personal. Commented May 9, 2017 at 12:41
2

Consider that you edited the code but you left in the "I just copy and paste the relevant code from the link here" bit of the answer - you turned that into a lie, after your edit it is no longer the code copy/pasted from the external site. If you do suggested edits - better edit everything or you can expect rejections.

Besides that...its tricky. The intent of the answer was clearly to do the minimal amount of effort and just dump the code from the external site - in improving that code and actually make it context-relevant you change the intent of the author. If you have a need to make it better, maybe you should in your own answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .