[M] Change in dart/sdk[main]: [analyzer] Fixes `initializing_formals` false-positive

0 views
Skip to first unread message

Felipe Morschel (Gerrit)

unread,
Jul 30, 2025, 9:56:11 AMJul 30
to dart-analys...@google.com, rev...@dartlang.org

Felipe Morschel has uploaded the change for review

Commit message

[analyzer] Fixes `initializing_formals` false-positive
Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997

Change information

Files:
  • M pkg/analyzer/lib/src/dart/analysis/analysis_context_collection.dart
  • M pkg/linter/lib/src/rules/prefer_initializing_formals.dart
  • M pkg/linter/test/rules/prefer_initializing_formals_test.dart
Change size: M
Delta: 3 files changed, 115 insertions(+), 18 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
Gerrit-Change-Number: 442801
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Jul 30, 2025, 9:58:37 AMJul 30
to Konstantin Shcheglov, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Samuel Rawlins

Felipe Morschel added 1 comment

File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
Line 20, Patchset 1 (Latest): void processExpression(Expression expression) {
Felipe Morschel . unresolved

At this point I wondered if making a small visitor only for assignment expressions wasn't best since I've not handled assignment expressions inside `if` and so many more cases...

I'll leave it up for you to decide if it is worth it.

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
Gerrit-Change-Number: 442801
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Wed, 30 Jul 2025 13:58:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Jul 30, 2025, 12:20:53 PMJul 30
to Felipe Morschel, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Konstantin Shcheglov

Samuel Rawlins added 1 comment

File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
Line 20, Patchset 1 (Latest): void processExpression(Expression expression) {
Felipe Morschel . unresolved

At this point I wondered if making a small visitor only for assignment expressions wasn't best since I've not handled assignment expressions inside `if` and so many more cases...

I'll leave it up for you to decide if it is worth it.

Samuel Rawlins

Yeah I think an actual AstVisitor would be better, and also quite idiomatic. If the question is "does this thing ever happen anywhere inside this method body (or expression, I suppose)", then an AstVisitor is the way to go, and should remain very simple.

The only caution you might want to take is to only visit a function body once, tracking all of the variables that are ever assigned. Just for performance reasons.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Konstantin Shcheglov
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
Gerrit-Change-Number: 442801
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Comment-Date: Wed, 30 Jul 2025 16:20:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Jul 30, 2025, 12:44:50 PMJul 30
to Konstantin Shcheglov, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Samuel Rawlins

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
Line 20, Patchset 1: void processExpression(Expression expression) {
Felipe Morschel . resolved

At this point I wondered if making a small visitor only for assignment expressions wasn't best since I've not handled assignment expressions inside `if` and so many more cases...

I'll leave it up for you to decide if it is worth it.

Samuel Rawlins

Yeah I think an actual AstVisitor would be better, and also quite idiomatic. If the question is "does this thing ever happen anywhere inside this method body (or expression, I suppose)", then an AstVisitor is the way to go, and should remain very simple.

The only caution you might want to take is to only visit a function body once, tracking all of the variables that are ever assigned. Just for performance reasons.

Felipe Morschel

I think the RecursiveAstVisitor should be fine for this. Much cleaner too.

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
Gerrit-Change-Number: 442801
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Wed, 30 Jul 2025 16:44:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Jul 30, 2025, 1:10:22 PMJul 30
to Felipe Morschel, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Konstantin Shcheglov

Samuel Rawlins voted and added 2 comments

Votes added by Samuel Rawlins

Code-Review+1

2 comments

File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
Line 45, Patchset 2 (Latest): List<AssignmentExpression> assignments = [];
Samuel Rawlins . unresolved

nit: can be final.

Line 52, Patchset 2 (Latest): static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
Samuel Rawlins . unresolved

nit: spelling: 'Below'

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Konstantin Shcheglov
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
    Gerrit-Change-Number: 442801
    Gerrit-PatchSet: 2
    Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Comment-Date: Wed, 30 Jul 2025 17:10:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Felipe Morschel (Gerrit)

    unread,
    Jul 30, 2025, 1:27:47 PMJul 30
    to Samuel Rawlins, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Konstantin Shcheglov and Samuel Rawlins

    Felipe Morschel voted and added 2 comments

    Votes added by Felipe Morschel

    Auto-Submit+1

    2 comments

    File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
    Line 45, Patchset 2: List<AssignmentExpression> assignments = [];
    Samuel Rawlins . resolved

    nit: can be final.

    Felipe Morschel

    Done

    Line 52, Patchset 2: static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
    Samuel Rawlins . resolved

    nit: spelling: 'Below'

    Felipe Morschel

    Thanks for catching that!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Konstantin Shcheglov
    • Samuel Rawlins
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: sdk
      Gerrit-Branch: main
      Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
      Gerrit-Change-Number: 442801
      Gerrit-PatchSet: 2
      Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
      Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
      Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
      Gerrit-Comment-Date: Wed, 30 Jul 2025 17:27:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
      unsatisfied_requirement
      open
      diffy

      Konstantin Shcheglov (Gerrit)

      unread,
      Jul 30, 2025, 1:29:33 PMJul 30
      to Felipe Morschel, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
      Attention needed from Felipe Morschel and Samuel Rawlins

      Konstantin Shcheglov added 1 comment

      File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
      Line 52, Patchset 2: static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
      Samuel Rawlins . unresolved

      nit: spelling: 'Below'

      Konstantin Shcheglov

      Sorry, below what?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Felipe Morschel
      • Samuel Rawlins
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: sdk
      Gerrit-Branch: main
      Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
      Gerrit-Change-Number: 442801
      Gerrit-PatchSet: 3
      Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
      Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
      Gerrit-Comment-Date: Wed, 30 Jul 2025 17:29:30 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
      unsatisfied_requirement
      open
      diffy

      Felipe Morschel (Gerrit)

      unread,
      Jul 30, 2025, 1:33:00 PMJul 30
      to Samuel Rawlins, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
      Attention needed from Konstantin Shcheglov and Samuel Rawlins

      Felipe Morschel voted and added 1 comment

      Votes added by Felipe Morschel

      Auto-Submit+1

      1 comment

      File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
      Line 52, Patchset 2: static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
      Samuel Rawlins . unresolved

      nit: spelling: 'Below'

      Konstantin Shcheglov

      Sorry, below what?

      Felipe Morschel

      Below the given body node. Maybe the naming is incorrect?

      I meant `If any children (grandchildren, etc) of the given body is an assignment expression, it will be added to the list and returned`.

      Should I replace the wording? Prehaps add docs?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Konstantin Shcheglov
      • Samuel Rawlins
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: sdk
      Gerrit-Branch: main
      Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
      Gerrit-Change-Number: 442801
      Gerrit-PatchSet: 3
      Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
      Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
      Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
      Gerrit-Comment-Date: Wed, 30 Jul 2025 17:32:57 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
      Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
      unsatisfied_requirement
      open
      diffy

      Konstantin Shcheglov (Gerrit)

      unread,
      Jul 30, 2025, 3:04:21 PMJul 30
      to Felipe Morschel, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
      Attention needed from Felipe Morschel and Samuel Rawlins

      Konstantin Shcheglov voted and added 1 comment

      Votes added by Konstantin Shcheglov

      Code-Review+1

      1 comment

      File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
      Line 52, Patchset 2: static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
      Samuel Rawlins . unresolved

      nit: spelling: 'Below'

      Konstantin Shcheglov

      Sorry, below what?

      Felipe Morschel

      Below the given body node. Maybe the naming is incorrect?

      I meant `If any children (grandchildren, etc) of the given body is an assignment expression, it will be added to the list and returned`.

      Should I replace the wording? Prehaps add docs?

      Konstantin Shcheglov

      OK, now I understand.
      It is "below" in a tree meaning.
      I'd use "in" word, but as it is, it is OK too.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Felipe Morschel
      • Samuel Rawlins
      Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: sdk
        Gerrit-Branch: main
        Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
        Gerrit-Change-Number: 442801
        Gerrit-PatchSet: 3
        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
        Gerrit-Comment-Date: Wed, 30 Jul 2025 19:04:17 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Felipe Morschel (Gerrit)

        unread,
        Jul 30, 2025, 3:58:39 PMJul 30
        to Konstantin Shcheglov, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
        Attention needed from Konstantin Shcheglov and Samuel Rawlins

        Felipe Morschel voted and added 1 comment

        Votes added by Felipe Morschel

        Auto-Submit+1

        1 comment

        File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
        Line 52, Patchset 2: static List<AssignmentExpression> assignmentsBellow(FunctionBody body) {
        Samuel Rawlins . resolved

        nit: spelling: 'Below'

        Konstantin Shcheglov

        Sorry, below what?

        Felipe Morschel

        Below the given body node. Maybe the naming is incorrect?

        I meant `If any children (grandchildren, etc) of the given body is an assignment expression, it will be added to the list and returned`.

        Should I replace the wording? Prehaps add docs?

        Konstantin Shcheglov

        OK, now I understand.
        It is "below" in a tree meaning.
        I'd use "in" word, but as it is, it is OK too.

        Felipe Morschel

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Konstantin Shcheglov
        • Samuel Rawlins
        Submit Requirements:
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: sdk
          Gerrit-Branch: main
          Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
          Gerrit-Change-Number: 442801
          Gerrit-PatchSet: 3
          Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
          Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
          Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
          Gerrit-Comment-Date: Wed, 30 Jul 2025 19:58:37 +0000
          unsatisfied_requirement
          open
          diffy

          Konstantin Shcheglov (Gerrit)

          unread,
          Jul 30, 2025, 3:59:25 PMJul 30
          to Felipe Morschel, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
          Attention needed from Felipe Morschel and Samuel Rawlins

          Konstantin Shcheglov voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Felipe Morschel
          • Samuel Rawlins
          Submit Requirements:
            • requirement is not satisfiedCode-Owners
            • requirement satisfiedCode-Review
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: sdk
            Gerrit-Branch: main
            Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
            Gerrit-Change-Number: 442801
            Gerrit-PatchSet: 4
            Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
            Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
            Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
            Gerrit-Comment-Date: Wed, 30 Jul 2025 19:59:22 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Samuel Rawlins (Gerrit)

            unread,
            Jul 30, 2025, 9:28:32 PMJul 30
            to Felipe Morschel, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
            Attention needed from Felipe Morschel

            Samuel Rawlins voted

            Code-Review+1
            Commit-Queue+2
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Felipe Morschel
            Submit Requirements:
            • requirement satisfiedCode-Owners
            • requirement satisfiedCode-Review
            • requirement satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: sdk
            Gerrit-Branch: main
            Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
            Gerrit-Change-Number: 442801
            Gerrit-PatchSet: 4
            Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
            Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
            Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Comment-Date: Thu, 31 Jul 2025 01:28:30 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            open
            diffy

            Felipe Morschel (Gerrit)

            unread,
            Jul 31, 2025, 8:53:49 AMJul 31
            to Samuel Rawlins, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
            Attention needed from Konstantin Shcheglov and Samuel Rawlins

            Felipe Morschel voted and added 1 comment

            Votes added by Felipe Morschel

            Auto-Submit+1

            1 comment

            File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
            Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
            Felipe Morschel . resolved

            Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Konstantin Shcheglov
            • Samuel Rawlins
            Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
              Gerrit-Comment-Date: Thu, 31 Jul 2025 12:53:46 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              open
              diffy

              Samuel Rawlins (Gerrit)

              unread,
              Aug 5, 2025, 12:26:16 AMAug 5
              to Felipe Morschel, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel and Konstantin Shcheglov

              Samuel Rawlins added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
              Felipe Morschel . unresolved

              Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

              Samuel Rawlins

              and without the `return` at the end (or else) then `test_assignedParameter_if` would break.

              I'm confused about this bit. Are you saying that the code _might_ be concerning because it requires an early return if `usedParameters.isNotEmpty`? Because then we don't call `super.visitIfStatement`? That is strange. Why does `test_assignedParameter_if` fail if you don't `return` (and thus call `super.visitIfStatement`)?

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              • Konstantin Shcheglov
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Tue, 05 Aug 2025 04:26:11 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
              unsatisfied_requirement
              open
              diffy

              Felipe Morschel (Gerrit)

              unread,
              Aug 5, 2025, 8:31:49 AMAug 5
              to Samuel Rawlins, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Konstantin Shcheglov and Samuel Rawlins

              Felipe Morschel added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
              Felipe Morschel . unresolved

              Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

              Samuel Rawlins

              and without the `return` at the end (or else) then `test_assignedParameter_if` would break.

              I'm confused about this bit. Are you saying that the code _might_ be concerning because it requires an early return if `usedParameters.isNotEmpty`? Because then we don't call `super.visitIfStatement`? That is strange. Why does `test_assignedParameter_if` fail if you don't `return` (and thus call `super.visitIfStatement`)?

              Felipe Morschel

              Sorry I wrote down the other way around.

              Without `return` (or else) then `test_withConditionalAssignment` would break because it would be looking for inner assignments normally without considering that it could have been used in a condition.

              Then if we _don't_ use the super call for the "`else`" case, `test_assignedParameter_if` would break.

              I would also like to ask about other conditions like `for`, `while`, `switch` guards... Maybe we could handle all but I'm not sure.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Konstantin Shcheglov
              • Samuel Rawlins
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
              Gerrit-Comment-Date: Tue, 05 Aug 2025 12:31:46 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
              Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
              unsatisfied_requirement
              open
              diffy

              Felipe Morschel (Gerrit)

              unread,
              Aug 12, 2025, 5:52:54 PMAug 12
              to Samuel Rawlins, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Samuel Rawlins

              Felipe Morschel added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
              Felipe Morschel . unresolved

              Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

              Samuel Rawlins

              and without the `return` at the end (or else) then `test_assignedParameter_if` would break.

              I'm confused about this bit. Are you saying that the code _might_ be concerning because it requires an early return if `usedParameters.isNotEmpty`? Because then we don't call `super.visitIfStatement`? That is strange. Why does `test_assignedParameter_if` fail if you don't `return` (and thus call `super.visitIfStatement`)?

              Felipe Morschel

              Sorry I wrote down the other way around.

              Without `return` (or else) then `test_withConditionalAssignment` would break because it would be looking for inner assignments normally without considering that it could have been used in a condition.

              Then if we _don't_ use the super call for the "`else`" case, `test_assignedParameter_if` would break.

              I would also like to ask about other conditions like `for`, `while`, `switch` guards... Maybe we could handle all but I'm not sure.

              Felipe Morschel

              Friendly ping @sraw...@google.com

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Samuel Rawlins
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
              Gerrit-Comment-Date: Tue, 12 Aug 2025 21:52:51 +0000
              unsatisfied_requirement
              open
              diffy

              Samuel Rawlins (Gerrit)

              unread,
              Aug 16, 2025, 2:32:48 PMAug 16
              to Felipe Morschel, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel

              Samuel Rawlins added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
              Felipe Morschel . unresolved

              Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

              Samuel Rawlins

              and without the `return` at the end (or else) then `test_assignedParameter_if` would break.

              I'm confused about this bit. Are you saying that the code _might_ be concerning because it requires an early return if `usedParameters.isNotEmpty`? Because then we don't call `super.visitIfStatement`? That is strange. Why does `test_assignedParameter_if` fail if you don't `return` (and thus call `super.visitIfStatement`)?

              Felipe Morschel

              Sorry I wrote down the other way around.

              Without `return` (or else) then `test_withConditionalAssignment` would break because it would be looking for inner assignments normally without considering that it could have been used in a condition.

              Then if we _don't_ use the super call for the "`else`" case, `test_assignedParameter_if` would break.

              I would also like to ask about other conditions like `for`, `while`, `switch` guards... Maybe we could handle all but I'm not sure.

              Felipe Morschel

              Friendly ping @sraw...@google.com

              Samuel Rawlins

              Sorry, I'm working on something a bit pressing this week; hopefully I can review at the end of the week.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Sat, 16 Aug 2025 18:32:45 +0000
              unsatisfied_requirement
              open
              diffy

              Samuel Rawlins (Gerrit)

              unread,
              Aug 25, 2025, 1:03:22 AMAug 25
              to Felipe Morschel, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel

              Samuel Rawlins added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5 (Latest): if (usedParameters.isNotEmpty) {
              Felipe Morschel . unresolved

              Without this part, the new `test_withConditionalAssignment` fils and without the `return` at the end (or else) then `test_assignedParameter_if` would break. I think this is good but I'd love your opinions on this.

              Samuel Rawlins

              and without the `return` at the end (or else) then `test_assignedParameter_if` would break.

              I'm confused about this bit. Are you saying that the code _might_ be concerning because it requires an early return if `usedParameters.isNotEmpty`? Because then we don't call `super.visitIfStatement`? That is strange. Why does `test_assignedParameter_if` fail if you don't `return` (and thus call `super.visitIfStatement`)?

              Felipe Morschel

              Sorry I wrote down the other way around.

              Without `return` (or else) then `test_withConditionalAssignment` would break because it would be looking for inner assignments normally without considering that it could have been used in a condition.

              Then if we _don't_ use the super call for the "`else`" case, `test_assignedParameter_if` would break.

              I would also like to ask about other conditions like `for`, `while`, `switch` guards... Maybe we could handle all but I'm not sure.

              Felipe Morschel

              Friendly ping @sraw...@google.com

              Samuel Rawlins

              Sorry, I'm working on something a bit pressing this week; hopefully I can review at the end of the week.

              Samuel Rawlins

              OK I see. This shouldn't be too crazy. I think all we need to do is store a stack of used parameters on this visitor. And store something like a "am I in a condition" bool. I think this `visitIfStatement` would look something like:

              ```
              visitIfStatement(IfStatement node) {
              var previousInCondition = inCondition;
              inBool = true;
              // push empty list of used parameters.
              node.condition.accept(this);
              inCondition = previousInCondition;
              node.then.accept(this);
              node.else.accept(this);
              // pop empty list of used parameters.
              }

              ```

              and that would be used in `visitSimpleIdentifier`:

              ```dart
              void visitSimpleIdentifier(SimpleIdentifier node) {
              if (node.element is in parameters && inCondition) {
              // add node.element to usedParameters
              }
              super.visitSimpleIdentifier();
              }
              ```

              and `visitAssignmentExpression` would be something like:

              ```dart
              visitAssignmentExpression(AssignmentExpression node) {
              // if node's assignee is in the used parameters list, then report!
              super.visitAssignmentExpression(node);
              }
              ```
              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Mon, 25 Aug 2025 05:03:19 +0000
              unsatisfied_requirement
              open
              diffy

              Brian Wilkerson (Gerrit)

              unread,
              Aug 25, 2025, 11:57:42 AMAug 25
              to Felipe Morschel, Brian Wilkerson, Samuel Rawlins, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel

              Brian Wilkerson added 1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Brian Wilkerson

              You do need to be careful about the case where the visitor reaches a nested closure (function body). Then you need to reset `isBool` to `false` and restore it's previous value when you leave the closure.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Mon, 25 Aug 2025 15:57:40 +0000
              unsatisfied_requirement
              open
              diffy

              Felipe Morschel (Gerrit)

              unread,
              Aug 26, 2025, 10:28:57 AMAug 26
              to Brian Wilkerson, Samuel Rawlins, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Brian Wilkerson and Samuel Rawlins

              Felipe Morschel voted and added 1 comment

              Votes added by Felipe Morschel

              Auto-Submit+1

              1 comment

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 62, Patchset 5: if (usedParameters.isNotEmpty) {
              Felipe Morschel . resolved
              Felipe Morschel

              I think the changes I made are complete. I'm going to mark this as resolved and if you think about something else we can discuss in more specific comments. Thanks for the help!

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Brian Wilkerson
              • Samuel Rawlins
              Submit Requirements:
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: sdk
              Gerrit-Branch: main
              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
              Gerrit-Change-Number: 442801
              Gerrit-PatchSet: 5
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Comment-Date: Tue, 26 Aug 2025 14:28:53 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
              Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
              Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
              unsatisfied_requirement
              open
              diffy

              Samuel Rawlins (Gerrit)

              unread,
              Aug 26, 2025, 1:55:20 PMAug 26
              to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Brian Wilkerson and Felipe Morschel

              Samuel Rawlins voted and added 7 comments

              Votes added by Samuel Rawlins

              Code-Review+1

              7 comments

              Patchset-level comments
              File-level comment, Patchset 6 (Latest):
              Samuel Rawlins . resolved

              Very cool!

              File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
              Line 51, Patchset 6 (Latest): final assignments = <AssignmentExpression>[];
              Samuel Rawlins . unresolved

              This is cool; this is now a very robust check with this visitor. And much more elegant than I was picturing.

              Since this visitor is non-trivial, we should now document the fields here, since they change a lot. And we should probably write a few sentences in a comment on the class itself explaining specifically how `_processConditions` works with `visitAssignmentExpression` and `visitSimpleIdentifier`.

              Line 55, Patchset 6 (Latest): var closure = false;
              Samuel Rawlins . unresolved

              I think this should be called `inClosure`, to be consistent.

              Line 118, Patchset 6 (Latest): inCondition) {
              Samuel Rawlins . unresolved

              Let's make this the first condition to check. It's false any time where not, well, in a condition, so it should usually be false, letting us short-circuit.

              File pkg/linter/test/rules/prefer_initializing_formals_test.dart
              Line 108, Patchset 6 (Latest): test_assignedInClosure() async {
              Samuel Rawlins . unresolved

              I think we need to track 'inClosure' again keeping the previous value. For example, here's a good test:

              ```
              class C {
              int? x;
              C(int x) {
              foo(() {
              foo(() {this.x = x;});
              // Oops, 'inClosure' better still be true.
              this.x = x;
              });
              }
              }
              ```
              Line 371, Patchset 6 (Latest): test_withConditionalAssignment_for() async {
              Samuel Rawlins . unresolved

              With the addition of handling loops (for, while, and do-while), I think we actually don't even need to check the condition. I feel like any assignment to `this.x` in a loop means we should not report lint. In your case here, you have a break, but that seems like the exception, the standard might be more like:

              ```
              class C {
              late List<String> x;
              C(List<String> x) {
              for (var e in ['a', 'b', 'c']) {
              x.add(e);
              this.x = x;
              }
              }
              }
              ```

              WDYT?

              Line 457, Patchset 6 (Latest): test_withConditionalAssignment_while() async {
              Samuel Rawlins . unresolved

              Love these new tests; I don't see an example with `do-while` though.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Brian Wilkerson
              • Felipe Morschel
              Submit Requirements:
                • requirement is not satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement is not satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: sdk
                Gerrit-Branch: main
                Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                Gerrit-Change-Number: 442801
                Gerrit-PatchSet: 6
                Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Comment-Date: Tue, 26 Aug 2025 17:55:16 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: Yes
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Felipe Morschel (Gerrit)

                unread,
                Aug 26, 2025, 1:59:41 PMAug 26
                to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                Attention needed from Samuel Rawlins

                Felipe Morschel voted and added 1 comment

                Votes added by Felipe Morschel

                Auto-Submit+1

                1 comment

                File pkg/linter/test/rules/prefer_initializing_formals_test.dart
                Line 457, Patchset 6 (Latest): test_withConditionalAssignment_while() async {
                Samuel Rawlins . unresolved

                Love these new tests; I don't see an example with `do-while` though.

                Felipe Morschel

                I wasn't sure if it would add any value. Since it would simply "do" first. Should I add it anyway? I wouldn't expect it to break ever but who knows.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Samuel Rawlins
                Submit Requirements:
                • requirement is not satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement is not satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: sdk
                Gerrit-Branch: main
                Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                Gerrit-Change-Number: 442801
                Gerrit-PatchSet: 6
                Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                Gerrit-Comment-Date: Tue, 26 Aug 2025 17:59:37 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: Yes
                Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
                unsatisfied_requirement
                satisfied_requirement
                open
                diffy

                Felipe Morschel (Gerrit)

                unread,
                Aug 26, 2025, 4:13:43 PMAug 26
                to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                Attention needed from Samuel Rawlins

                Felipe Morschel voted and added 5 comments

                Votes added by Felipe Morschel

                Auto-Submit+1

                5 comments

                File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
                Line 51, Patchset 6: final assignments = <AssignmentExpression>[];
                Samuel Rawlins . resolved

                This is cool; this is now a very robust check with this visitor. And much more elegant than I was picturing.

                Since this visitor is non-trivial, we should now document the fields here, since they change a lot. And we should probably write a few sentences in a comment on the class itself explaining specifically how `_processConditions` works with `visitAssignmentExpression` and `visitSimpleIdentifier`.

                Felipe Morschel

                Done

                Line 55, Patchset 6: var closure = false;
                Samuel Rawlins . resolved

                I think this should be called `inClosure`, to be consistent.

                Felipe Morschel

                Done

                Line 118, Patchset 6: inCondition) {
                Samuel Rawlins . resolved

                Let's make this the first condition to check. It's false any time where not, well, in a condition, so it should usually be false, letting us short-circuit.

                Felipe Morschel

                Great idea!

                File pkg/linter/test/rules/prefer_initializing_formals_test.dart
                Line 108, Patchset 6: test_assignedInClosure() async {
                Samuel Rawlins . resolved

                I think we need to track 'inClosure' again keeping the previous value. For example, here's a good test:

                ```
                class C {
                int? x;
                C(int x) {
                foo(() {
                foo(() {this.x = x;});
                // Oops, 'inClosure' better still be true.
                this.x = x;
                });
                }
                }
                ```
                Felipe Morschel

                Great cath! I was going to miss this case.

                Line 371, Patchset 6: test_withConditionalAssignment_for() async {
                Samuel Rawlins . unresolved

                With the addition of handling loops (for, while, and do-while), I think we actually don't even need to check the condition. I feel like any assignment to `this.x` in a loop means we should not report lint. In your case here, you have a break, but that seems like the exception, the standard might be more like:

                ```
                class C {
                late List<String> x;
                C(List<String> x) {
                for (var e in ['a', 'b', 'c']) {
                x.add(e);
                this.x = x;
                }
                }
                }
                ```

                WDYT?

                Felipe Morschel

                Any case? Or only when we "use" `x` like accessing `add` and such? Because if we don't alter the value of the parameter, we could probably make it an initializing formal parameter. I've made the changes considering this, any objections?

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Samuel Rawlins
                Submit Requirements:
                  • requirement is not satisfiedCode-Owners
                  • requirement is not satisfiedCode-Review
                  • requirement is not satisfiedReview-Enforcement
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: sdk
                  Gerrit-Branch: main
                  Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                  Gerrit-Change-Number: 442801
                  Gerrit-PatchSet: 7
                  Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                  Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                  Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                  Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                  Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                  Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                  Gerrit-Comment-Date: Tue, 26 Aug 2025 20:13:40 +0000
                  unsatisfied_requirement
                  open
                  diffy

                  Samuel Rawlins (Gerrit)

                  unread,
                  Aug 26, 2025, 6:09:16 PMAug 26
                  to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                  Attention needed from Felipe Morschel

                  Samuel Rawlins added 2 comments

                  File pkg/linter/test/rules/prefer_initializing_formals_test.dart
                  Line 371, Patchset 6: test_withConditionalAssignment_for() async {
                  Samuel Rawlins . resolved

                  With the addition of handling loops (for, while, and do-while), I think we actually don't even need to check the condition. I feel like any assignment to `this.x` in a loop means we should not report lint. In your case here, you have a break, but that seems like the exception, the standard might be more like:

                  ```
                  class C {
                  late List<String> x;
                  C(List<String> x) {
                  for (var e in ['a', 'b', 'c']) {
                  x.add(e);
                  this.x = x;
                  }
                  }
                  }
                  ```

                  WDYT?

                  Felipe Morschel

                  Any case? Or only when we "use" `x` like accessing `add` and such? Because if we don't alter the value of the parameter, we could probably make it an initializing formal parameter. I've made the changes considering this, any objections?

                  Samuel Rawlins

                  It's so far-fetched... these loops and such. It really probably doesn't matter what we do here. But I like your idea of using the data of whether x is "used".

                  Line 457, Patchset 6: test_withConditionalAssignment_while() async {
                  Samuel Rawlins . unresolved

                  Love these new tests; I don't see an example with `do-while` though.

                  Felipe Morschel

                  I wasn't sure if it would add any value. Since it would simply "do" first. Should I add it anyway? I wouldn't expect it to break ever but who knows.

                  Samuel Rawlins

                  Here, I'm thinking again of assigning `this.x` in a loop. Seems like any situation like this is not a situation where we should report this lint. Including a do-while.

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Felipe Morschel
                  Submit Requirements:
                  • requirement is not satisfiedCode-Owners
                  • requirement is not satisfiedCode-Review
                  • requirement is not satisfiedReview-Enforcement
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: sdk
                  Gerrit-Branch: main
                  Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                  Gerrit-Change-Number: 442801
                  Gerrit-PatchSet: 7
                  Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                  Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                  Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                  Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                  Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                  Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                  Gerrit-Comment-Date: Tue, 26 Aug 2025 22:09:13 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  unsatisfied_requirement
                  open
                  diffy

                  Samuel Rawlins (Gerrit)

                  unread,
                  Aug 26, 2025, 6:09:21 PMAug 26
                  to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                  Attention needed from Felipe Morschel

                  Samuel Rawlins voted Code-Review+1

                  Code-Review+1
                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Felipe Morschel
                  Submit Requirements:
                    • requirement is not satisfiedCode-Owners
                    • requirement satisfiedCode-Review
                    • requirement is not satisfiedReview-Enforcement
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: sdk
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                    Gerrit-Change-Number: 442801
                    Gerrit-PatchSet: 7
                    Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                    Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                    Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                    Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                    Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                    Gerrit-Comment-Date: Tue, 26 Aug 2025 22:09:19 +0000
                    Gerrit-HasComments: No
                    Gerrit-Has-Labels: Yes
                    unsatisfied_requirement
                    satisfied_requirement
                    open
                    diffy

                    Felipe Morschel (Gerrit)

                    unread,
                    Aug 26, 2025, 11:38:58 PMAug 26
                    to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                    Attention needed from Samuel Rawlins

                    Felipe Morschel voted and added 1 comment

                    Votes added by Felipe Morschel

                    Auto-Submit+1

                    1 comment

                    File pkg/linter/test/rules/prefer_initializing_formals_test.dart
                    Line 457, Patchset 6: test_withConditionalAssignment_while() async {
                    Samuel Rawlins . resolved

                    Love these new tests; I don't see an example with `do-while` though.

                    Felipe Morschel

                    I wasn't sure if it would add any value. Since it would simply "do" first. Should I add it anyway? I wouldn't expect it to break ever but who knows.

                    Samuel Rawlins

                    Here, I'm thinking again of assigning `this.x` in a loop. Seems like any situation like this is not a situation where we should report this lint. Including a do-while.

                    Felipe Morschel

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Samuel Rawlins
                    Submit Requirements:
                      • requirement is not satisfiedCode-Owners
                      • requirement is not satisfiedCode-Review
                      • requirement is not satisfiedReview-Enforcement
                      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                      Gerrit-MessageType: comment
                      Gerrit-Project: sdk
                      Gerrit-Branch: main
                      Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                      Gerrit-Change-Number: 442801
                      Gerrit-PatchSet: 8
                      Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                      Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                      Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                      Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                      Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                      Gerrit-Comment-Date: Wed, 27 Aug 2025 03:38:54 +0000
                      Gerrit-HasComments: Yes
                      Gerrit-Has-Labels: Yes
                      unsatisfied_requirement
                      open
                      diffy

                      Samuel Rawlins (Gerrit)

                      unread,
                      Aug 27, 2025, 9:49:19 AMAug 27
                      to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                      Attention needed from Felipe Morschel

                      Samuel Rawlins voted and added 1 comment

                      Votes added by Samuel Rawlins

                      Code-Review+1

                      1 comment

                      Patchset-level comments
                      File-level comment, Patchset 8 (Latest):
                      Samuel Rawlins . resolved

                      Looks great!

                      Open in Gerrit

                      Related details

                      Attention is currently required from:
                      • Felipe Morschel
                      Submit Requirements:
                        • requirement is not satisfiedCode-Owners
                        • requirement satisfiedCode-Review
                        • requirement is not satisfiedReview-Enforcement
                        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                        Gerrit-MessageType: comment
                        Gerrit-Project: sdk
                        Gerrit-Branch: main
                        Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                        Gerrit-Change-Number: 442801
                        Gerrit-PatchSet: 8
                        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                        Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Comment-Date: Wed, 27 Aug 2025 13:49:16 +0000
                        Gerrit-HasComments: Yes
                        Gerrit-Has-Labels: Yes
                        unsatisfied_requirement
                        satisfied_requirement
                        open
                        diffy

                        Felipe Morschel (Gerrit)

                        unread,
                        Aug 27, 2025, 10:30:09 AMAug 27
                        to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                        Attention needed from Samuel Rawlins

                        Felipe Morschel added 1 comment

                        Patchset-level comments
                        Felipe Morschel . unresolved

                        @sraw...@google.com I can't see the failure for the g3 bot.

                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Samuel Rawlins
                        Submit Requirements:
                        • requirement is not satisfiedCode-Owners
                        • requirement satisfiedCode-Review
                        • requirement is not satisfiedReview-Enforcement
                        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                        Gerrit-MessageType: comment
                        Gerrit-Project: sdk
                        Gerrit-Branch: main
                        Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                        Gerrit-Change-Number: 442801
                        Gerrit-PatchSet: 8
                        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                        Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                        Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                        Gerrit-Comment-Date: Wed, 27 Aug 2025 14:30:05 +0000
                        Gerrit-HasComments: Yes
                        Gerrit-Has-Labels: No
                        unsatisfied_requirement
                        satisfied_requirement
                        open
                        diffy

                        Samuel Rawlins (Gerrit)

                        unread,
                        Aug 27, 2025, 10:49:08 AMAug 27
                        to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                        Attention needed from Felipe Morschel

                        Samuel Rawlins added 1 comment

                        Patchset-level comments
                        Felipe Morschel . unresolved

                        @sraw...@google.com I can't see the failure for the g3 bot.

                        Samuel Rawlins

                        That bot is basically reporting timeouts. I'm looking for an infinite loop...

                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Felipe Morschel
                        Submit Requirements:
                        • requirement is not satisfiedCode-Owners
                        • requirement satisfiedCode-Review
                        • requirement is not satisfiedReview-Enforcement
                        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                        Gerrit-MessageType: comment
                        Gerrit-Project: sdk
                        Gerrit-Branch: main
                        Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                        Gerrit-Change-Number: 442801
                        Gerrit-PatchSet: 8
                        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                        Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Comment-Date: Wed, 27 Aug 2025 14:49:05 +0000
                        Gerrit-HasComments: Yes
                        Gerrit-Has-Labels: No
                        Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
                        unsatisfied_requirement
                        satisfied_requirement
                        open
                        diffy

                        Samuel Rawlins (Gerrit)

                        unread,
                        Aug 27, 2025, 10:57:04 AMAug 27
                        to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                        Attention needed from Felipe Morschel

                        Samuel Rawlins added 1 comment

                        File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
                        Line 146, Patchset 8 (Latest): super.visitIfStatement(node);
                        Samuel Rawlins . unresolved

                        I think the timeout in the g3 bot is due to this double visiting: `_newScopeForUsedParameters` takes each node it is handed, and calls `node.accept(this)`. _Then_ `super.visitIfStatement(node)` visits the children again. That sort of represents just a 2x in visits, and maybe does not represent a functional incorrectness. But these visits are recursive. So if you have 4 if-statements nested, then we visit the children of the outermost if-statement 2 times, and children of the next if-statement 4 times; we visit the next if-statement's children 8 times, and the last one's children 16 times.

                        I think each function which calls `_newScopeForUsedParameters` should not call `super.visit...`. It needs to carefully have specific children accept this visitor.

                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Felipe Morschel
                        Submit Requirements:
                        • requirement is not satisfiedCode-Owners
                        • requirement satisfiedCode-Review
                        • requirement is not satisfiedReview-Enforcement
                        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                        Gerrit-MessageType: comment
                        Gerrit-Project: sdk
                        Gerrit-Branch: main
                        Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                        Gerrit-Change-Number: 442801
                        Gerrit-PatchSet: 8
                        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                        Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                        Gerrit-Comment-Date: Wed, 27 Aug 2025 14:57:01 +0000
                        Gerrit-HasComments: Yes
                        Gerrit-Has-Labels: No
                        unsatisfied_requirement
                        satisfied_requirement
                        open
                        diffy

                        Felipe Morschel (Gerrit)

                        unread,
                        Aug 27, 2025, 3:25:54 PMAug 27
                        to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                        Attention needed from Samuel Rawlins

                        Felipe Morschel voted and added 1 comment

                        Votes added by Felipe Morschel

                        Auto-Submit+1

                        1 comment

                        File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
                        Line 146, Patchset 8: super.visitIfStatement(node);
                        Samuel Rawlins . resolved

                        I think the timeout in the g3 bot is due to this double visiting: `_newScopeForUsedParameters` takes each node it is handed, and calls `node.accept(this)`. _Then_ `super.visitIfStatement(node)` visits the children again. That sort of represents just a 2x in visits, and maybe does not represent a functional incorrectness. But these visits are recursive. So if you have 4 if-statements nested, then we visit the children of the outermost if-statement 2 times, and children of the next if-statement 4 times; we visit the next if-statement's children 8 times, and the last one's children 16 times.

                        I think each function which calls `_newScopeForUsedParameters` should not call `super.visit...`. It needs to carefully have specific children accept this visitor.

                        Felipe Morschel

                        I've did some refactoring. Mind running it again for me please? I can close the other comment if it passes. Thanks!

                        Open in Gerrit

                        Related details

                        Attention is currently required from:
                        • Samuel Rawlins
                        Submit Requirements:
                          • requirement is not satisfiedCode-Owners
                          • requirement is not satisfiedCode-Review
                          • requirement is not satisfiedReview-Enforcement
                          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                          Gerrit-MessageType: comment
                          Gerrit-Project: sdk
                          Gerrit-Branch: main
                          Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                          Gerrit-Change-Number: 442801
                          Gerrit-PatchSet: 8
                          Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                          Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                          Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                          Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                          Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                          Gerrit-Comment-Date: Wed, 27 Aug 2025 19:25:50 +0000
                          Gerrit-HasComments: Yes
                          Gerrit-Has-Labels: Yes
                          Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
                          unsatisfied_requirement
                          open
                          diffy

                          Samuel Rawlins (Gerrit)

                          unread,
                          Aug 27, 2025, 5:17:55 PMAug 27
                          to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                          Attention needed from Felipe Morschel

                          Samuel Rawlins voted and added 1 comment

                          Votes added by Samuel Rawlins

                          Code-Review+1

                          1 comment

                          File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
                          Line 129, Patchset 9 (Latest): _newScopeForUsedParameters([?condition, node.body]);
                          Samuel Rawlins . unresolved

                          This one's going to be tricky to get perfectly right, I think. You definitely still want to visit all children, one way or another. In this case, you want to make sure to visit the other for-loop parts. An example would be _very_ contrived. But you know, there could be something like `for (var e in a.map((x) => x == parameter))`.

                          Open in Gerrit

                          Related details

                          Attention is currently required from:
                          • Felipe Morschel
                          Submit Requirements:
                            • requirement is not satisfiedCode-Owners
                            • requirement satisfiedCode-Review
                            • requirement is not satisfiedReview-Enforcement
                            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                            Gerrit-MessageType: comment
                            Gerrit-Project: sdk
                            Gerrit-Branch: main
                            Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                            Gerrit-Change-Number: 442801
                            Gerrit-PatchSet: 9
                            Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                            Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                            Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                            Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                            Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                            Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                            Gerrit-Comment-Date: Wed, 27 Aug 2025 21:17:52 +0000
                            Gerrit-HasComments: Yes
                            Gerrit-Has-Labels: Yes
                            unsatisfied_requirement
                            satisfied_requirement
                            open
                            diffy

                            Felipe Morschel (Gerrit)

                            unread,
                            Aug 28, 2025, 11:55:36 AMAug 28
                            to Samuel Rawlins, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                            Attention needed from Samuel Rawlins

                            Felipe Morschel voted and added 2 comments

                            Votes added by Felipe Morschel

                            Auto-Submit+1

                            2 comments

                            Patchset-level comments
                            Felipe Morschel . unresolved

                            @sraw...@google.com I can't see the failure for the g3 bot.

                            Samuel Rawlins

                            That bot is basically reporting timeouts. I'm looking for an infinite loop...

                            Felipe Morschel

                            It seems like it still had errors. Not sure if it is the same thing? I wasn't expecting it to be failing.

                            File pkg/linter/lib/src/rules/prefer_initializing_formals.dart
                            Line 129, Patchset 9: _newScopeForUsedParameters([?condition, node.body]);
                            Samuel Rawlins . resolved

                            This one's going to be tricky to get perfectly right, I think. You definitely still want to visit all children, one way or another. In this case, you want to make sure to visit the other for-loop parts. An example would be _very_ contrived. But you know, there could be something like `for (var e in a.map((x) => x == parameter))`.

                            Felipe Morschel

                            I think the implementation is better now. Thanks for the example!

                            Open in Gerrit

                            Related details

                            Attention is currently required from:
                            • Samuel Rawlins
                            Submit Requirements:
                              • requirement is not satisfiedCode-Owners
                              • requirement is not satisfiedCode-Review
                              • requirement is not satisfiedReview-Enforcement
                              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                              Gerrit-MessageType: comment
                              Gerrit-Project: sdk
                              Gerrit-Branch: main
                              Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                              Gerrit-Change-Number: 442801
                              Gerrit-PatchSet: 9
                              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                              Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                              Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                              Gerrit-Comment-Date: Thu, 28 Aug 2025 15:55:32 +0000
                              Gerrit-HasComments: Yes
                              Gerrit-Has-Labels: Yes
                              unsatisfied_requirement
                              open
                              diffy

                              Samuel Rawlins (Gerrit)

                              unread,
                              Nov 28, 2025, 6:16:20 PM (2 days ago) Nov 28
                              to Felipe Morschel, Brian Wilkerson, Commit Queue, Konstantin Shcheglov, dart-analys...@google.com, rev...@dartlang.org
                              Attention needed from Felipe Morschel

                              Samuel Rawlins voted Code-Review+1

                              Code-Review+1
                              Open in Gerrit

                              Related details

                              Attention is currently required from:
                              • Felipe Morschel
                              Submit Requirements:
                                • requirement is not satisfiedCode-Owners
                                • requirement satisfiedCode-Review
                                • requirement is not satisfiedReview-Enforcement
                                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                                Gerrit-MessageType: comment
                                Gerrit-Project: sdk
                                Gerrit-Branch: main
                                Gerrit-Change-Id: Ibfd6913af31ed638f2033d9d9e78d71636579997
                                Gerrit-Change-Number: 442801
                                Gerrit-PatchSet: 10
                                Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                                Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                                Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
                                Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                                Gerrit-CC: Brian Wilkerson <brianwi...@google.com>
                                Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                                Gerrit-Comment-Date: Fri, 28 Nov 2025 23:16:16 +0000
                                Gerrit-HasComments: No
                                Gerrit-Has-Labels: Yes
                                unsatisfied_requirement
                                satisfied_requirement
                                open
                                diffy
                                Reply all
                                Reply to author
                                Forward
                                0 new messages