C#: Add test showing false positive

This commit is contained in:
Calum Grant
2020-01-28 11:48:59 +00:00
parent 8c00671f24
commit f23438ea65
2 changed files with 4 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ class Test
var b = true;
b &= c.Method(); // GOOD
b |= c[0]; // GOOD
if (c == null | c.Method(out _)) ; // GOOD (false positive)
}
class C
@@ -28,6 +30,7 @@ class Test
public string Property { get; set; }
public bool this[int i] { get { return false; } set { } }
public bool Method() { return false; }
public bool Method(out int x) { x = 0; return false; }
}
}

View File

@@ -2,3 +2,4 @@
| DangerousNonShortCircuitLogic.cs:16:13:16:40 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
| DangerousNonShortCircuitLogic.cs:17:13:17:28 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
| DangerousNonShortCircuitLogic.cs:18:13:18:34 | ... \| ... | Potentially dangerous use of non-short circuit logic. |
| DangerousNonShortCircuitLogic.cs:24:13:24:39 | ... \| ... | Potentially dangerous use of non-short circuit logic. |