ruby-style-guide icon indicating copy to clipboard operation
ruby-style-guide copied to clipboard

Ignore the `test` method from parentheses cop

Open gmalette opened this issue 7 years ago • 5 comments

I'm quite reluctant to do this, but here's the proposition: not require parens for test method arguments.

My rationale is only that I'm afraid that having to write test("the thing works") will cause more friction than necessary, even though I'd be in favour of writing it that way.

The collision risk also has to be considered, but there are 6 test methods in Shopify/shopify, 5 of which return boolean, and none of them take parameters.

I'm really on the fence, and I'd like to know what y'all think before I start applying corrections to Shopify/shopify.

gmalette avatar Jan 09 '19 14:01 gmalette

I'm worried a future Predicate type could be introduced with test(object) method, which would be excluded. Perhaps we could ignore it only in the test folder? It would probably require changing the cop slightly but nothing we can't handle

gmalette avatar Jan 09 '19 14:01 gmalette

Since we are here for test, how about the RSpec methods (spec, describe, context, subject etc)?

rafaelfranca avatar Jan 21 '19 19:01 rafaelfranca

Since we are here for test, how about the RSpec methods (spec, describe, context, subject etc)?

For the methods which are not typically used elsewhere I wouldn't have a problem with that; it comes to mind where I don't think anyone would name a method like that.

To that end, I propose we just write a cop that allows excluding methods per file-pattern. This would let us allow test in _test.rb files, and rspec methods in _spec.rb files.

gmalette avatar Jan 28 '19 15:01 gmalette

I guess this is no longer needed?

volmer avatar May 24 '19 15:05 volmer

Depends what we do with #106

gmalette avatar May 24 '19 16:05 gmalette