You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that juniors tend to write code like this:
User.all.map{ |x| x.name}
I would love some checking of block variable name. I know it's kind of hard because of suggesting u or user as variable name for first example and suggesting c or comments for second example:
Post.first.comments.map{ |x| x.body}
It could be detected by checking the method name of enumerated chain. If it's plural, it good and it's like comments example.
But it makes examples like this impossible to work with (so much cringe):
flower=User.allflower.map{ |x| x.name}
But I would expect the cop to suggest f or flower as block variable name
Also taking all first letters from snake_case as suggestion:
product_type_versions => ptv or product_type_version
EDIT:
It could probably be described better, like: block variable name should be related to context
The text was updated successfully, but these errors were encountered:
Looks like a duplicate of #3666. Please follow that issue for updates. 🙂
I would expect the cop to suggest f or flower as block variable name
Unfortunately making the cop smart enough to suggest names is not possible. This is beacause methods can be chained, and we can't know which method refers to the thing being referenced in the block. It would likely also require us to depend on some inflection library.
Please apply
# rubocop:disable Style/SymbolProc
For examples below
I noticed that juniors tend to write code like this:
I would love some checking of block variable name. I know it's kind of hard because of suggesting
u
oruser
as variable name for first example and suggestingc
orcomments
for second example:It could be detected by checking the method name of enumerated chain. If it's plural, it good and it's like
comments
example.But it makes examples like this impossible to work with (so much cringe):
But I would expect the cop to suggest
f
orflower
as block variable nameAlso taking all first letters from snake_case as suggestion:
product_type_versions =>
ptv
orproduct_type_version
EDIT:
It could probably be described better, like: block variable name should be related to context
The text was updated successfully, but these errors were encountered: