From 347e5dae0bcddeacdf584569914a369e2c3a24f0 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 26 Jun 2026 12:11:38 +0100 Subject: [PATCH 1/2] Update STYLEGUIDE.md to clarify block usage Removed examples and arguments against multiline chaining with `{...}` in the style guide. This is too much churn for little value. The monolith had >2000 offenses never corrected, and the alternative syntaxes just add more toil. --- STYLEGUIDE.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index f14d1000..f0e8e244 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -843,8 +843,7 @@ arr.each { |elem| puts elem } * Prefer `{...}` over `do...end` for single-line blocks. Avoid using `{...}` for multi-line blocks (multiline chaining is always ugly). Always use `do...end` for "control flow" and "method - definitions" (e.g. in Rakefiles and certain DSLs). Avoid `do...end` - when chaining. + definitions" (e.g. in Rakefiles and certain DSLs). [[link](#squiggly-braces)] * RuboCop rule: Style/BlockDelimiters @@ -858,20 +857,8 @@ names.each { |name| puts name } names.each do |name| puts name end - -# good -names.select { |name| name.start_with?("S") }.map { |name| name.upcase } - -# bad -names.select do |name| - name.start_with?("S") -end.map { |name| name.upcase } ``` -* Some will argue that multiline chaining would look OK with the use of `{...}`, - but they should ask themselves: is this code really readable and can't the block's - contents be extracted into nifty methods? - * Avoid `return` where not required. [[link](#avoid-return)] * RuboCop rule: Style/RedundantReturn From 6f8b0e55669e5e70cfac5f68d405f1b0863aaa8d Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 26 Jun 2026 12:17:17 +0100 Subject: [PATCH 2/2] Remove more multi-line chaining ugliness references --- STYLEGUIDE.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index f0e8e244..f76fb1e9 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -840,9 +840,8 @@ end arr.each { |elem| puts elem } ``` -* Prefer `{...}` over `do...end` for single-line blocks. Avoid using - `{...}` for multi-line blocks (multiline chaining is always - ugly). Always use `do...end` for "control flow" and "method +* Prefer `{...}` over `do...end` for single-line blocks. Avoid using + `{...}` for multi-line blocks. Always use `do...end` for "control flow" and "method definitions" (e.g. in Rakefiles and certain DSLs). [[link](#squiggly-braces)] * RuboCop rule: Style/BlockDelimiters