Notes for writing Ruby code Annotations:
Write the code of the self-explanatory document and let this part rest. This does not mean playing.
Write comments in English.
Use a space to separate comments from symbols.
When more than one word is commented, the first sentence should be capitalized and punctuation marks should be used. Use a space after the end
Avoid unnecessary comments.
# bad counter += 1 # increments counter by one
Update comments at any time. No comments are better than expired ones.
Do not write comments for bad code. Refactor them to make them "self-explanatory ". (Do or do not-there is no try .)
The annotation should be written above the relevant code.
The annotation keyword is followed by a colon and space, and then a record describing the problem.
If multiple lines are required to describe the problem, the subsequent lines must be indented with two spaces after.
def bar # FIXME: This has crashed occasionally since v3.2.1. It may # be related to the BarBazUtil upgrade. baz(:quux) end
If the problem is obvious, any document will be redundant. Annotations can also be (non-compliant) at the end of the line without any remarks. This usage should not be generally used or a rule.
def bar sleep 100 # OPTIMIZE end
Use TODO to comment on missing features or add features later.
Use FIXME to note the code to be fixed.
Use OPTIMIZE to note slow or inefficient code that may cause performance problems.
The use of HACK to comment on the use of problematic code may need to be reconstructed.
Use REVIEW to note the code that requires repeated check and confirmation. For example, REVIEW: Are you sure how the client completes X correctly?
Use another custom keyword if you think it is appropriate, but make sure that it is specified in your project's README or similar.