Reviewing Code Edits
When in doubt, click 'Skip'. "Learn to love that Skip button."
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 unless the lack of indentation is relevant to the question
- Add line breaks
- Fix syntax (non-closed brackets, missing semi-colons, etc.) if you are sure that it is not relevant to the question
- Fix typos (misspelled function calls, variable names, etc.) if you are sure that it is not relevant to the question
While you're there:
- Improve the title to match the question content
- Edit tags to match the question
- Remember: Tags should help to describe what the question is about, not just what it contains.
- Fix any spelling/grammar errors outside of the code block
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, 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.)
Example
Original Question:
[PROBLEM] My SQL is foobar (returns nothing)
SELECT TgName, COUNT(*) AS UpVotes FROM Tags INNER JOIN
PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON
Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId =
Posts.Id and VoteTypeId = 2 WHERE Posts.OwnerUserId = @UserId GROUP BY
TagName ORDER BY UpVotes DESC
Good Edit:
Query Returning No Values
I want my query to return foo, but it is returning nothing instead.
Here is my code:
SELECT
TgName,
COUNT(*) AS UpVotes
FROM Tags
INNER JOIN PostTags ON PostTags.TagId = Tags.id
INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 2
WHERE
Posts.OwnerUserId = @UserId
GROUP BY TagName
ORDER BY UpVotes DESC
Title was made more descriptive, the code was formatted properly, and an explanation of the question was added to the body rather than just having a code dump.
Bad Edit:
[PROBLEM] My SQL is foobar (returns nothing)
SELECT
TagName,
COUNT(*) AS UpVotes
FROM Tags
INNER JOIN PostTags ON PostTags.TagId = Tags.id
INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 2
WHERE
Posts.OwnerUserId = @UserId
GROUP BY TagName
ORDER BY UpVotes DESC
The problem in the original question was due to TagName
being misspelled as TgName
; since that was fixed in the edit, the query will work and the problem becomes hidden. Despite improving the code, the title is still undescriptive and hasn't been fixed.
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.)
Example:
Original Answer:
I think able enough in this code, please check.
$('body').keypress(function(e)
{
if (e.keyCode == '13')
{
e.stopPropragation();
}
});
Good Edit:
This code should work though may need adjustment.
$('body').keypress(function(e)
{
if (e.keyCode == '13')
{
e.stopPropagation();
}
});
The code was using stopPropragation()
instead of stopPropagation()
so that was fixed, the body was edited to be clear to an English speaker, and the indentation was made consistent to improve the code's formatting.
Bad Edit:
I think able enough in this code, please check.
$('body').keypress(function (e) {
if (e.keyCode === 13) {
e.stopPropragation();
}
});
A few coding and style issues that didn't prevent the code from working were changed, while the show-stopper with stopPropragation()
and the nonsensical English was left as-is.
Suggested Edits for Code
If you do not have 2,000 reputation allowing you to edit without review, you should be sure to include a good Edit Summary. Reviewers may not be an expert in the language you are submitting an edit for, and may click 'Reject' if they aren't sure if your edit meets these guidelines. Adding a good Edit Summary will help minimize the chance of them making the wrong decision.
Example:
Good Edit Summary
Corrected typo in a function call (stopPropragation() to stopPropagation()); made indentation consistent
By clearly explaining what the content of the change was and the reason, you are able to direct the reviewer to what they need to look at.
Bad Edit Summary
Fixed Code
If you just say something short like 'edited code' then it is far more likely that the reviewer will have to guess at the reason and intent, and reject the edit if they can't be sure it was appropriate.