Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: Revise rule about braces #61

Merged

Conversation

nekketsuuu
Copy link
Contributor

This pull request revises the following rule for Ruby:

[SHOULD] Distinguish between using a hash and using keyword arguments in method calls.

Context: See #60.

This PR closes #60.

ruby.ja.md Outdated
@@ -379,14 +379,26 @@ Ruby プログラマとしての素養をある程度備えている者なら誰
- その他、DSL のために用意されていると考えられるメソッド。
- メソッド呼び出しを入れ子にする場合、他の規則で禁止されている場合を除いて、最も外側のメソッド呼び出しの括弧を省略してもよい。
- **[MUST]** メソッド名とメソッド呼び出しの括弧の間に空白を入れてはならない。
- **[SHOULD]** パラメータリストの末尾にハッシュリテラルを書く場合は、ハッシュリテラルの括弧を省略すること
- **[SHOULD]** メソッド呼び出しでは、キーワード引数に渡しているのかハッシュオブジェクトを渡しているのかを区別する
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/cookpad/styleguide/blob/590bca6dafc9f879518fc0190f0d023387066e31/ruby.ja.md#%E6%96%87%E5%AD%97%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%81%A8%E3%83%9E%E3%82%B8%E3%83%83%E3%82%AF%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88 の「Ruby 2.0 以降は UTF-8 がデフォルトになったので」と同様に、「Ruby 3 以降はキーワード引数とハッシュオブジェクトが区別されるようになるので」みたいな理由付けがあると分かりやすそう。

@nekketsuuu
Copy link
Contributor Author

@eagletmt https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ を参考に「分離」という言葉を使って理由を書いてみました。

@nekketsuuu nekketsuuu force-pushed the nekketsuuu-BracesAroundHashParameters branch from 8820289 to 8ea42fb Compare April 13, 2020 07:42
@nekketsuuu
Copy link
Contributor Author

レビューありがとうございました。マージします。

@nekketsuuu nekketsuuu merged commit 47fd7fa into cookpad:master Apr 13, 2020
@nekketsuuu nekketsuuu deleted the nekketsuuu-BracesAroundHashParameters branch April 13, 2020 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ruby: Revise a rule related to optional arguments and keyword arguments
2 participants