very_good_analysis icon indicating copy to clipboard operation
very_good_analysis copied to clipboard

fix: Clashing rules: omit_obvious_property_types and type_annotate_public_apis

Open frankvollebregt opened this issue 7 months ago • 1 comments

Description

Since the 8.0.0 release candidate 1, the omit_obvious_property_types rule is part of the analysis options. While I like it, and it seems pretty nice, I unfortunately encountered an incompatibility between it and the type_annotate_public_apis rule.

https://github.com/dart-lang/sdk/issues/60642

Until there is some resolution there, I suppose it might be easiest to disable this rule again? (or if there are any other ideas to make it work, that's even better)

Steps To Reproduce

I have a private class (name preceded with _), and in this class I'm declaring a variable.

class _Developer {
  bool likesDart = true;
}

This results in ("bool" is highlighted)

The type annotation isn't needed because it is obvious. (omit_obvious_property_types)

When I apply the autofix it becomes

class _Developer {
  var likesDart = true;
}

But now, this results in ("likesDart" is highlighted)

Missing type annotation on a public API. (type_annotate_public_apis)

And I go back and forth between these two.

Expected Behavior

I expect the rules defined by this (very good!) package not to conflict amongst each other

Additional Context

Here's the issue I originally opened (which was closed because it duplicates the one I linked above): https://github.com/dart-lang/sdk/issues/60734

frankvollebregt avatar May 15 '25 18:05 frankvollebregt

This one indeed seem to be indeed incorrectly giving a warning about the type annotation. I am going to remove it from the v8 lint rules and we can keep this issue open to track if/when this problem gets solved upstream.

Thanks for bringing it to our attention!

wolfenrain avatar May 21 '25 11:05 wolfenrain