From ef8506813db292a083a4411b9e1265a572ce0ddb Mon Sep 17 00:00:00 2001 From: AllanSiqueira Date: Sat, 3 Oct 2020 21:33:44 -0300 Subject: [PATCH] [Fix #7495] Documentation for `Lint/AmbiguousBlockAssociation` Add example on documentation for `Lint/AmbiguousBlockAssociation` to make clear the possible resolutions --- CHANGELOG.md | 2 ++ docs/modules/ROOT/pages/cops_lint.adoc | 2 ++ lib/rubocop/cop/lint/ambiguous_block_association.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41df973a415..fa08b699890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * [#8843](https://github.com/rubocop-hq/rubocop/issues/8843): Fix an incorrect autocorrect for `Lint/AmbiguousRegexpLiteral` when sending method to regexp literal receiver. ([@koic][]) * [#8842](https://github.com/rubocop-hq/rubocop/issues/8842): Save actual status to cache, except corrected. ([@hatkyinc2][]) * [#8835](https://github.com/rubocop-hq/rubocop/issues/8835): Fix an incorrect autocorrect for `Style/RedundantInterpolation` when using string interpolation for non-operator methods. ([@koic][]) +* [#7495](https://github.com/rubocop-hq/rubocop/issues/7495): Example for `Lint/AmbiguousBlockAssociation` cop. ([@AllanSiqueira][]) ### Changes @@ -4956,3 +4957,4 @@ [@rdunlop]: https://github.com/rdunlop [@ghiculescu]: https://github.com/ghiculescu [@hatkyinc2]: https://github.com/hatkyinc2 +[@AllanSiqueira]: https://github.com/allansiqueira diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc index 4d90bd50937..6b26ad6745a 100644 --- a/docs/modules/ROOT/pages/cops_lint.adoc +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -27,6 +27,8 @@ some_method a { |val| puts val } ---- # good # With parentheses, there's no ambiguity. +some_method(a { |val| puts val }) +# or (different meaning) some_method(a) { |val| puts val } # good diff --git a/lib/rubocop/cop/lint/ambiguous_block_association.rb b/lib/rubocop/cop/lint/ambiguous_block_association.rb index 94ffc47401c..acae23147d7 100644 --- a/lib/rubocop/cop/lint/ambiguous_block_association.rb +++ b/lib/rubocop/cop/lint/ambiguous_block_association.rb @@ -15,6 +15,8 @@ module Lint # # # good # # With parentheses, there's no ambiguity. + # some_method(a { |val| puts val }) + # # or (different meaning) # some_method(a) { |val| puts val } # # # good