Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invariant_booleans works incorrectly in switch #58571

Closed
EvGeniyLell opened this issue Nov 18, 2021 · 3 comments
Closed

invariant_booleans works incorrectly in switch #58571

EvGeniyLell opened this issue Nov 18, 2021 · 3 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@EvGeniyLell
Copy link

invariant_booleans works incorrectly in switch
in second examination buffer i have the analizator problem

Conditions should not unconditionally evaluate to true or to false. verify: buffer != null.

      switch (callbackType) {
        case dto.GeneratePdfCallbacks.progress:
          if (buffer != null) {
            onProgress(
              DtoPdfDocumentValue.proggresFomGeneratePdfProgressBuffer(buffer),
            );
            return;
          }
          break;
        case dto.GeneratePdfCallbacks.complete:
          if (buffer != null) { /// <- at this place
            onComplete(
              DtoPdfDocument.fromGeneratePdfCompleteBuffer(buffer),
            );
            return;
          }
          break;
        default:
          super.callback(index, buffer);
          break;
      }

I think it is wrong behavior.

@srawlins srawlins transferred this issue from dart-lang/sdk Nov 22, 2021
@pq pq added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Nov 22, 2021
@pq
Copy link
Member

pq commented Nov 22, 2021

Thanks for the report @EvGeniyLell. This lint has a number of known issues and could definitely use some attention (or deprecation and removal). Sorry for the inconvenience.

@swch01
Copy link

swch01 commented Oct 7, 2022

Possible duplicates: #57601 and #57551

@srawlins
Copy link
Member

We've deprecated invariant_booleans and will not be fixing correctness bugs going forward.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants