32

I found a well-received but link-only answer.

I attempted to edit the answer to copy the linked article into a blockquote but I found out that the code has a bunch of syntax errors (it looks like a data transmission issue, missing parentheses everywhere). The overall logic of the code looks sound.

Would it be wrong to fix the mistakes in the code in the blockquote? Or should I just leave a note saying that the code needs some fixes? … Or just leave it as-is?

10
  • 13
    If you're 100% sure the quoted material has syntax errors, then sure, fix while you edit it in the answer but I would also state in the answer that you did so.
    – rene
    Jun 10, 2017 at 19:47
  • 14
    I avoid this issue completely by simply pointing out that the code has errors and providing my own original snippet as a replacement. If the text directly references the code, I go one step further and avoid quoting the text altogether, opting instead to paraphrase it in a way that's relevant to the question and not dependent on the erroneous code.
    – BoltClock
    Jun 11, 2017 at 2:37
  • 13
    If you put something in quotes, or quote formatting, then you should copy it exactly, with errors. You can note that the errors are in the original. If you're going to change it substantially, then it's not a quote. If the license for the material permits you to do so, you can create a "derivative work" by copying the code and fixing the errors. You should link to the source and note that you have fixed errors. However, determining if the license under which the code was published permits you to re-publish it may be difficult. If you can't confirm that it's permitted, you should not do it.
    – Makyen Mod
    Jun 11, 2017 at 18:52
  • 16
    This question also seems to be specific to errors in code - errors in prose are easily indicated with a well-placed [sic].
    – BoltClock
    Jun 12, 2017 at 4:43
  • @BoltClock Would you do that by editing the answer, or by providing a whole new answer altogether? Jun 12, 2017 at 5:53
  • 5
    @Kodos Johnson: I would provide a new answer altogether. It doesn't change the other answer being link-only, but I don't fancy the idea of putting my own words into other people's mouths. In situations like this I think it really is up to whomever posted the link-only answer to figure out how best to integrate the content into their own answer.
    – BoltClock
    Jun 12, 2017 at 6:00
  • 1
    Regardless of whether the answer has a lot of upvotes, link-only answers should be closed. I daresay that if you'd included a link to the answer in your question that would already have happened. Jun 12, 2017 at 10:53
  • 1
    But answers can't be closed. They can only be edited or deleted (or I guess deleted and edited and undeleted).
    – BoltClock
    Jun 12, 2017 at 15:43
  • 2
    If it has major mistakes what is the point of quoting it at all? And if you know better than your cited source, ditto?
    – user207421
    Jun 13, 2017 at 10:35
  • @BoltClock /* [sic] */ Jun 13, 2017 at 16:45

3 Answers 3

41

Working code is always better than broken code, regardless of the source of the code. If you're going to be posting code from an external resource that contains errors, it is a good idea to fix those errors; but also remember to note that you have fixed the quoted code, and that the original source does contain errors.

10

Fixing minor / insignificant errors in quoted material is acceptable ... and even a good idea in the case of quoted code. There is even a convention for doing this in English text: enclose the corrected part of the text in square brackets. Alternatively, it wouldn't do any harm to remark that you have fixed minor errors.

Fixing significant errors is dubious. By significant, I mean changes that substantially alter the meaning of the text you quoted. If you do that, the original author (and the readers) are likely to question your honesty. (Deliberately misquoting someone as saying one thing when they actually said something else is ... basically ... lying.) And even if you think you know what the original author was trying to say, you could be wrong. People don't like "having words put into their mouths", to use a common English idiom.

In the case of code with major errors, there is an easy solution. Just say that your version of the code is based on the original version, and cite the original so that the author gets credit. Everyone should be happy with that (modulo that there is no overt copyright violation ....)

4

I just quote and link to the very nice comment by Makyen that, in my opinion, answers the question.

"If you put something in quotes, or quote formatting, then you should copy it exactly, with errors. You can note that the errors are in the original. If you're going to change it substantially, then it's not a quote. If the license for the material permits you to do so, you can create a "derivative work" by copying the code and fixing the errors. You should link to the source and note that you have fixed errors. [..]"

The comment has been shortened to the parts that are, in my opinion, essential to the question. Unfortunately I didn't find any mistake to correct. If so, I would have mentioned it here.


I also could have said that I think that quotes should not be altered in any way (or they shouldn't be quotes). That only leaves the possibility to mention any errors additionally or not quoting at all. Not quoting would mean creating a derivative work, which of course should be as error free as possible. This paragraph is a derivative work of this comment by Makyen, which I'm permitted to do because the comment was posted on StackOverflow. Would there have been any errors in the comment, I would have eliminated them before writing this paragraph. (That may be a reason to prefer creating derivative works instead of quoting long passages of text and code unless said text and code is spot on and error free.)

You must log in to answer this question.

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