Skip to content

Enable Style/ObjectThen to enforce `then` instead of `yield_self`

What does this MR do and why?

From https://rubystyle.guide/#object-yield-self-vs-object-then

The method Object#then is preferred over Object#yield_self, since the name then states the intention, not the behavior. This makes the resulting code easier to read.

# bad
obj.yield_self { |x| x.do_something }

# good
obj.then { |x| x.do_something }

Refs gitlab-triage!291 (comment 1598551797)

Impact on gitlab-org/gitlab

$ be rubocop -P -f o --only Style/ObjectThen
 33677/33677 files |==================================== 100 ====================================>| Time: 00:00:06

11  Style/ObjectThen
--
11  Total in 10 files
Edited by Peter Leitzen

Merge request reports

Loading