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
Cop idea: standardize on #then
instead of #yield_self
#10522
Labels
Comments
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 11, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names from the Object class. You can customize the mapping from undesired method to desired method. e.g. to use `yield_self` over `then`: ```yaml Style/CollectionMethods: PreferredMethods: then: yield_self ``` ## example ```ruby # bad obj.yield_self # good obj.then ```
8 tasks
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 12, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 12, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 16, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 19, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
ydah
added a commit
to ydah/rubocop
that referenced
this issue
Apr 19, 2022
Resolve: rubocop#10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
bbatsov
pushed a commit
that referenced
this issue
Apr 20, 2022
Resolve: #10522. This cop enforces the use of consistent method names `Object#yield_self` or `Object#then`. ## example ```ruby # EnforcedStyle: then (default) # bad obj.yield_self { |x| x.do_something } # good obj.then { |x| x.do_something } ``` ```ruby # EnforcedStyle: yield_self # bad obj.then { |x| x.do_something } # good obj.yield_self { |x| x.do_something } ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dgollahon commentedApr 10, 2022
Is your feature request related to a problem? Please describe.
It seems like it would be nice to have a consistent style for
then
v.s.yield_self
like there are cops for someEnumerable
methods.Describe the solution you'd like
A new cop with autocorrect (maybe configurable style?) that converts
#yield_self
to#then
. It would be unsafe to autocorrect.Describe alternatives you've considered
N/A
Additional context
Not sure this is a high priority/huge need, but I thought I would share the idea. Thanks!
The text was updated successfully, but these errors were encountered: