3
$\begingroup$

Our current Help Center->Our Model page gives the following guidance on edits.

Edits are expected to be substantial and to leave the post better than you found it. Common reasons for edits include:

  • To fix grammar and spelling mistakes
  • To clarify the meaning of the post (without changing that meaning)
  • To include additional information only found in comments, so all of the information relevant to the post is contained in one place
  • To correct minor mistakes or add updates as the post ages
  • To add related resources or hyperlinks

When should I make edits to code?

What are the guidelines for editing someone else's code in a

  • Question?
  • Answer?
$\endgroup$
5
$\begingroup$

I believe the StackOverflow canonical answer on this is useful (excerpts below).

Editing Code in Questions

Code in questions should only be edited for formatting and readability. Editing the syntax or correcting typos in code in questions can fix the problem that the person asking the question has, causing answers to be unable to address the problem.

Do:

  • Add code blocks around code
  • Add indentation
  • Add line breaks
  • Improve the title to match the question content
  • Edit tags to match the question
  • Fix any spelling/grammar errors outside of the code block
  • Fix Syntax (non-closed brackets, missing semi-colons, etc.), unless they are relevant to the question
  • Fix typos (misspelled function calls, variable names, etc.), unless they are relevant to the question

Don't:

  • Change code conventions (delimited_names to camelCase names, etc.)
  • Change the code logic or functionality
  • Fix or change the problem that's being asked about
  • Copy code from a linked site into the question [1][1], [2][2]
  • Transcribe code from an image to text. It's just too easy to introduce new errors.
  • Ignore improvements that can be made outside the code block (spelling, grammar, etc.)

Editing Code in Answers

Answers are intended to be resources for future visitors. While quick and dirty answers are useful, they may have errors in syntax due to being typed in without being checked first, and could have room for improvement. Unlike questions, making an answer work is a good thing and should be encouraged with a few guidelines to follow.

Do:

  • Test your edited code to make sure it works
  • Fix syntax errors and typos If changing the syntax errors or typos would result in the code doing something other than what the answer says it will, consider creating a comment or a separate answer explaining your change. If posting another answer with only that change seems like it won't provide added value to future visitors, it probably doesn't change logic or functionality and should be an edit instead.
  • Improve formatting
  • Correct spelling/grammar issues in the answer body

Don't:

  • Change code conventions (delimited_names to camelCase names, etc.)
  • Make the code do something different than what the answer says it does
  • Ignore improvements that can be made outside the code block (spelling, grammar, etc.)
$\endgroup$

You must log in to answer this question.

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