CARVIEW |
Select Language
HTTP/2 301
date: Sun, 03 Aug 2025 03:16:11 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
location: https://github.com/leahneukirchen/styleguide/raw/master/RUBY-STYLE
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
x-github-request-id: 8224:3630A:769FDC:9D11F7:688ED47B
HTTP/2 302
date: Sun, 03 Aug 2025 03:16:11 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
access-control-allow-origin:
location: https://raw.githubusercontent.com/leahneukirchen/styleguide/master/RUBY-STYLE
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
x-github-request-id: 8224:3630A:769FF1:9D1213:688ED47B
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: W/"94f44cbb7d9796605f37999ab29365a77465aa673e2a0d2e1723df2f2186da6b"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: B0FA:2AFEF0:1EB1FE:537FFD:688ED47A
content-encoding: gzip
accept-ranges: bytes
date: Sun, 03 Aug 2025 03:16:12 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210060-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1754190972.778688,VS0,VE225
vary: Authorization,Accept-Encoding
access-control-allow-origin: *
cross-origin-resource-policy: cross-origin
x-fastly-request-id: 014eb6cf6aca606561333317aa22e5a1765c03e5
expires: Sun, 03 Aug 2025 03:21:12 GMT
source-age: 0
content-length: 2167
= Leah Neukirchen's Ruby Style Guide
You may not like all rules presented here, but they work very well for
me and have helped producing high quality code. Everyone is free to
code however they want, write and follow their own style guides, but
when you contribute to my code, please follow these rules:
== Formatting:
* Use ASCII (or UTF-8, if you have to).
* Use 2 space indent, no tabs.
* Use Unix-style line endings. On the last line of the file, too.
* Use spaces around operators, after commas, colons and semicolons,
around { and before }.
* No spaces after (, [ and before ], ).
* Use two spaces before statement modifiers (postfix
if/unless/while/until/rescue).
* Indent when as deep as case.
* Use an empty line before the return value of a method (unless it
only has one line), and an empty line between defs.
* Use RDoc and its conventions for API documentation. Don't put an
empty line between the comment block and the def.
* Use empty lines to break up a long method into logical paragraphs.
* Keep lines fewer than 80 characters.
* Avoid trailing whitespace.
== Syntax:
* Use def with parentheses when there are arguments.
* Never use for, unless you exactly know why.
* Never use then.
* Use when x; ... for one-line cases.
* Use &&/|| for boolean expressions, and/or for control flow. (Rule
of thumb: If you have to use outer parentheses, you are using the
wrong operators.)
* Avoid multiline ?:, use if.
* Suppress superfluous parentheses when calling methods, but keep them
when calling "functions", i.e. when you use the return value in the
same line.
x = Math.sin(y)
array.delete e
* Prefer {...} over do...end. Multiline {...} is fine: having
different statement endings (} for blocks, end for if/while/...)
makes it easier to see what ends where. But use do...end for
"control flow" and "method definitions" (e.g. in Rakefiles and
certain DSLs.) Avoid do...end when chaining.
* Avoid return where not required.
* Avoid line continuation (\) where not required.
* Using the return value of = is okay:
if v = array.grep(/foo/) ...
* Use ||= freely.
* Use non-OO regexps (they won't make the code better). Freely use
=~, $0-9, $~, $` and $' when needed.
* Never use smalltalk: symbols.
== Naming:
* Use snake_case for methods.
* Use CamelCase for classes and modules. (Keep acronyms like HTTP,
RFC, XML uppercase.)
* Use SCREAMING_SNAKE_CASE for other constants.
* The length of an identifier determines its scope. Use one-letter
variables for short block/method parameters, according to this
scheme:
a,b,c: any object
d: directory names
e: elements of an Enumerable
ex: rescued exceptions
f: files and file names
i,j: indexes
k: the key part of a hash entry
m: methods
o: any object
r: return values of short methods
s: strings
v: any value
v: the value part of a hash entry
x,y,z: numbers
And in general, the first letter of the class name if all objects
are of that type.
* Use _ or names prefixed with _ for unused variables.
* When using inject with short blocks, name the arguments |a, e|
(mnemonic: accumulator, element)
* When defining binary operators, name the argument "other".
* Prefer map over collect, find over detect, find_all over select,
size over length.
== Comments:
* Comments longer than a word are capitalized and use punctuation.
Use two spaces after periods.
* Avoid superfluous comments.
== The rest:
* Write ruby -w safe code.
* Avoid hashes-as-optional-parameters. Does the method do too much?
* Avoid long methods.
* Avoid long parameter lists.
* Use def self.method to define singleton methods.
* Add "global" methods to Kernel (if you have to) and make them private.
* Avoid alias when alias_method will do.
* Use OptionParser for parsing complex command line options and
ruby -s for trivial command line options.
* Target Ruby 1.9.
* Avoid needless metaprogramming.
== General:
* Code in a functional way, avoid mutation when it makes sense.
* Do not mutate arguments unless that is the purpose of the method.
* Do not mess around in core classes when writing libraries.
* Do not program defensively.
(See https://www.erlang.se/doc/programming_rules.shtml#HDR11.)
* Keep the code simple.
* Don't overdesign.
* Don't underdesign.
* Avoid bugs.
* Read other style guides and apply the parts that don't dissent with
this list.
* Be consistent.
* Use common sense.