I would like a cop like Metrics/MethodLength but for blocks (as in do...end or {...}). I think this would be especially useful when using frameworks like Sinatra or Rake that heavily use methods with block parameters. (namespace, task, etc. in Rake; get, post, etc. with Sinatra.)
I am trying to implement this myself, but I'm getting a bit lost around AST-node pattern-matching.
$ rubocop -V
0.43.0
You don't really need any pattern matching to write this. You just have to process on_block method invocations.
Awesome, thanks for implementing this! :grinning:
Is there an easy way to disable this cop for RSpec tests but keep it enabled for all other codes?
You can exclude your rspec tests dir from this cop's config. Or place a different .rubocop.yml in your rspec dir.
Most helpful comment
You can exclude your
rspectests dir from this cop's config. Or place a different.rubocop.ymlin yourrspecdir.