Skip to content

Info level offenses for likely wrong RBS #347

Description

@sambostock

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`?

Footnotes

  1. too damn high

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions