S1940 — Boolean checks should not be inverted

Language
VB.NET
Type
Code smell
Severity
Minor
Tags
pitfall

Why is this an issue?

It is needlessly complex to invert the result of a boolean comparison. The opposite comparison should be made instead.

Noncompliant code example


If Not (a = 2) Then  // Noncompliant
Dim b as Boolean = Not (i < 10)  // Noncompliant

Compliant solution


If a <> 2 Then
Dim b as Boolean = i >= 10

↑ Back to top