
Issue #20922 has been updated by mame (Yusuke Endoh). FYI: https://github.com/ruby/ruby/commit/6a39e6fc2d0db590ad605f7af9c99d32c64c6a22 https://github.com/ruby/ruby/commit/fc67091fc8dc4c7122499cd0d287cd34ff01bf30 https://github.com/ruby/ruby/commit/5b146eb5a15cce4c7a6ce279bd53e75a61d4a1f5 https://github.com/rubygems/rubygems/commit/e6a538b5c8104900e9a74f6a5fd154da... https://github.com/rubygems/rubygems/commit/984bb9b81574e778b3d40d039761d842... https://github.com/rubygems/rubygems/commit/6ec39cd782d554127030ede12988f172... https://github.com/rails/rails/commit/e69a7ee42dc09892477808f1243d029ce1abf3... https://github.com/rails/rails/commit/ac721c855203ac7570545c0e85fe086f8e94d9... https://github.com/rails/rails/commit/951383bd9afa4a71c17e56d1d4eb5866da8514... https://github.com/rails/rails/commit/8a0f235fd3bd3f3c813fa7034c6d741831e55c... https://github.com/rails/rails/commit/99b48a5aebc0ff159a8102f2782eaee8ab5a32... https://github.com/rails/rails/commit/c33c03e80cbe9f27274b45fe55f93bad3af988... https://github.com/rails/rails/commit/f53f69bdc617d63587036cef84eb11ef2dfbc5... https://github.com/rails/rails/commit/7a65b463ab8d366db0cc49b9a49d37c59d4ce5... https://github.com/rails/rails/commit/82ba39202c9185af9060b70a8241cb41101364... https://github.com/rails/rails/commit/a2338c583349ebd48f3c9ec18f1df5c7cf21df... ... ---------------------------------------- Feature #20922: Should not we omit parentheses in assert calls? https://bugs.ruby-lang.org/issues/20922#change-110786 * Author: mame (Yusuke Endoh) * Status: Open ---------------------------------------- I often see the style of omitting parentheses in assert calls, but it leads to annoying warnings in the following case: ``` assert_equal -1, val #=> warning: ambiguous first argument; put parentheses or a space even after `-` operator assert_match /foo/, str #=> warning: ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator ``` To deal with this warning, it is necessary to add parentheses only to *some* assert calls. ``` assert_equal 1, one assert_equal 0, zero assert_equal(-1, minus_one) ``` Obviously, this is not very cool. I feel that by these warnings, Ruby says "we should not omit parentheses in assert calls". Is this what matz intended? If it is the intent, I would like to add parentheses on all assert calls in tests of Ruby and default gems. If it is not the intent, why don't we remove these warnings? Note that, as far as I recall, I encountered this problem only with `assert_equal` and `assert_match`. I don't write parentheses in `p`, `puts`, `attr_reader`, `include`, etc., but all of them rarely accept `-1` and `//` literally as the first argument in real code. As a milder approach, I came up with an idea to stop the warning only when the method name starts with "assert". It is very ad-hoc, though. -- https://bugs.ruby-lang.org/