Linter: provide a lint if a `@deprecated` annotation has no description of the deprecation

Created on 12 Jul 2018  路  5Comments  路  Source: dart-lang/linter

It's useful when deprecating functionality to indicate to the user what the recommended alternative is. So, instead of:

@deprecated
void foo() {
  ...
}

we should prefer:

@Deprecated('Prefer to use the bar() method')
void foo() {
  ...
}

/cc @kevmoo

enhancement lint request

Most helpful comment

We could always deprecate @deprecate 馃槃

All 5 comments

It's useful when deprecating functionality to indicate to the user what the recommended alternative is.

That's true, but that's not what the optional argument is used for:

  /**
   * Create a deprecation annotation which specifies the expiration of the
   * annotated feature.
   *
   * The [expires] argument should be readable by programmers, and should state
   * when an annotated feature is expected to be removed.
   * This can be specified, for example, as a date, as a release number, or
   * as relative to some other change (like "when bug 4418 is fixed").
   */
  const Deprecated(String expires) : this.expires = expires;

I've never seen it used for that purpose. We'd probably gather good info by surveying existing code, but generally, I don't think we should be limited by what that dartdoc comment says.

It sounds like we should update the docs regardless?

We could always deprecate @deprecate 馃槃

Okie doke, at some point, the description of the Deprecated constructor argument changed to this:

Create a deprecation annotation which specifies the migration path and expiration of the annotated feature.

The message argument should be readable by programmers, and should state an alternative feature (if available) as well as when an annotated feature is expected to be removed.

At this point, I think the original lint request is perfectly valid :)

Was this page helpful?
0 / 5 - 0 ratings