text stringlengths 0 444 |
|---|
end |
---- |
=== Inline Annotations [[rare-eol-annotations]] |
In cases where the problem is so obvious that any documentation would be redundant, annotations may be left at the end of the offending line with no note. |
This usage should be the exception and not the rule. |
[source,ruby] |
---- |
def bar |
sleep 100 # OPTIMIZE |
end |
---- |
=== `TODO` [[todo]] |
Use `TODO` to note missing features or functionality that should be added at a later date. |
=== `FIXME` [[fixme]] |
Use `FIXME` to note broken code that needs to be fixed. |
=== `OPTIMIZE` [[optimize]] |
Use `OPTIMIZE` to note slow or inefficient code that may cause performance problems. |
=== `HACK` [[hack]] |
Use `HACK` to note code smells where questionable coding practices were used and should be refactored away. |
=== `REVIEW` [[review]] |
Use `REVIEW` to note anything that should be looked at to confirm it is working as intended. |
For example: `REVIEW: Are we sure this is how the client does X currently?` |
=== Document Annotations [[document-annotations]] |
Use other custom annotation keywords if it feels appropriate, but be sure to document them in your project's `README` or similar. |
== Magic Comments |
=== Magic Comments First [[magic-comments-first]] |
Place magic comments above all code and documentation in a file (except shebangs, which are discussed next). |
[source,ruby] |
---- |
# bad |
# Some documentation about Person |
# frozen_string_literal: true |
class Person |
end |
# good |
# frozen_string_literal: true |
# Some documentation about Person |
class Person |
end |
---- |
=== Below Shebang [[below-shebang]] |
Place magic comments below shebangs when they are present in a file. |
[source,ruby] |
---- |
# bad |
# frozen_string_literal: true |
#!/usr/bin/env ruby |
App.parse(ARGV) |
# good |
#!/usr/bin/env ruby |
# frozen_string_literal: true |
App.parse(ARGV) |
---- |
=== One Magic Comment per Line [[one-magic-comment-per-line]] |
Use one magic comment per line if you need multiple. |
[source,ruby] |
---- |
# bad |
# -*- frozen_string_literal: true; encoding: ascii-8bit -*- |
# good |
# frozen_string_literal: true |
# encoding: ascii-8bit |
---- |
=== Separate Magic Comments from Code [[separate-magic-comments-from-code]] |
Separate magic comments from code and documentation with a blank line. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.