linter icon indicating copy to clipboard operation
linter copied to clipboard

invariant_booleans works incorrectly in switch

Open EvGeniyLell opened this issue 4 years ago • 2 comments

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.

EvGeniyLell avatar Nov 18 '21 23:11 EvGeniyLell

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.

pq avatar Nov 22 '21 17:11 pq

Possible duplicates: #720 and #1859

swch01 avatar Oct 07 '22 15:10 swch01

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

srawlins avatar Oct 24 '22 20:10 srawlins