Skip to content

invariant_booleans false positive #34173

Closed
@DanTup

Description

@DanTup

This may be a dupe of #28262, #29431 or #28967 but it looks different to me so I thought it worth raising.

var hasAnError = false;
void danny() {
  if (hasAnError) {
    return;
  }
  setError();
  if (hasAnError) { // Conditions should not unconditionally evaluate to `true` or to `false`.
    return;
  }
  print('Running');
}

void setError() {
  hasAnError = true;
}

I wouldn't expect it to look through all called code to see if the variable is set, but possibly it's a bit too keen to report here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions