Skip to content

public_member_api_docs quickfix for primary constructor "this;" insertion #64324

Description

@navaronbracke

This is a follow up to #64316

As of today the public_member_api_docs lint flags a primary constructor that does not have documentation.

There are two cases where it gets ambiguous:

  1. There is no this; declaration: The lint flags the line where the class is declared, i.e. class Foo( {, but then it is not obvious because there are class docs above it.
  2. There is a this; declaration, without a doc comment above it. The lint flags the line where the class is declared, i.e. class Foo( { and the this; declaration. Here you get two lint warnings, but the one on class Foo( { is the same ambiguity as noted above.

The quickfixes that I get today are:

  • ignores for the lint (line, file, analisys_options file; not very helpful)
  • convert to in-body constructor (unrelated)
  • add a name to the constructor (unrelated)

But nothing suggests adding this;.

I suggest a two fold fix:

  • New Quickfix: If there is no this;, then add it, which should move the linted line to the this; declaration (which still doesn't fix the lint, but now the warning is more clear)
  • Make it less ambiguous: If there is a this;, then lint only on that, instead of the primary constructor itself, since the warning is really about the this; missing a doc comment, and not the Foo() {

cc @bwilkerson @FMorschel

Dart SDK version: 3.13.3 (stable) (Tue Sep 1 01:07:17 2026 -0700) on "windows_x64"

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

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagedevexp-quick-fixIssues with analysis server (quick) fixestype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions