We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
# In controller def index params[:foo].something end
これは、paramsに値が入ってこなかったらエラーになって死ぬ。 なので、params.require(:foo).something か params[:foo]&.something になるべき。 (ただしnilに生えているメソッドは呼べる)
params.require(:foo).something
params[:foo]&.something
実装は多分簡単。
nil に生えているメソッドを呼び出しているケース(例えば、params[:foo].nil?)の対応は、 Lint/SafeNavigationChain とかを見ると良いと思う。 https://github.com/bbatsov/rubocop/blob/245155158db2d4e0d3d0da918d3e7f3bf6291e78/lib/rubocop/cop/lint/safe_navigation_chain.rb#L40 この nil に生えているメソッドのリストをいい感じに共通化したいけど、現状のRuboCopにはCop感をまたがるような設定はあまりいい感じに出来ないので、ちょっとむずかしい。
params[:foo].nil?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
これは、paramsに値が入ってこなかったらエラーになって死ぬ。
なので、
params.require(:foo).something
かparams[:foo]&.something
になるべき。(ただしnilに生えているメソッドは呼べる)
実装は多分簡単。
nil に生えているメソッドを呼び出しているケース(例えば、
params[:foo].nil?
)の対応は、 Lint/SafeNavigationChain とかを見ると良いと思う。 https://github.com/bbatsov/rubocop/blob/245155158db2d4e0d3d0da918d3e7f3bf6291e78/lib/rubocop/cop/lint/safe_navigation_chain.rb#L40この nil に生えているメソッドのリストをいい感じに共通化したいけど、現状のRuboCopにはCop感をまたがるような設定はあまりいい感じに出来ないので、ちょっとむずかしい。
The text was updated successfully, but these errors were encountered: