Context
Most RBS annotations are not of the form @key: value, so it is easy1: to forget the colon in annotations like
-# @requires_ancestor ::Whatever
+# @requires_ancestor: ::Whatever
This can be particularly frustrating when attempting to require a complex ancestor (such as a module including metaprogramming), where one might assume things aren't working because they are requiring the wrong ancestor, or because Sorbet is not statically aware of the method, when in fact it turns out they were simply silently not requiring any ancestor at all.
Proposal
It would be nice if there was a cop that looked for such comments that are probably a mistake and attached an info level warning, saving the developer time debugging.
# @requires_ancestor ::Whatever
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INFO: This looks like a malformed RBS annotation. Did you mean `@requires_ancestor: ::Whatever`?
Context
Most RBS annotations are not of the form
@key: value, so it is easy1: to forget the colon in annotations likeThis can be particularly frustrating when attempting to require a complex ancestor (such as a module including metaprogramming), where one might assume things aren't working because they are requiring the wrong ancestor, or because Sorbet is not statically aware of the method, when in fact it turns out they were simply silently not requiring any ancestor at all.
Proposal
It would be nice if there was a cop that looked for such comments that are probably a mistake and attached an info level warning, saving the developer time debugging.
Footnotes