mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C#: Add some tests for cs/useless-if-statement.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
class FutileConditionalTest
|
||||
{
|
||||
|
||||
public void M(string s)
|
||||
{
|
||||
if (s.Length > 0) ; // $ Alert
|
||||
|
||||
if (s.Length > 1)
|
||||
{
|
||||
} // $ Alert
|
||||
|
||||
if (s.Length > 2) // GOOD: because of else-branch
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("hello");
|
||||
}
|
||||
|
||||
if (s.Length > 3)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
} // $ Alert
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
| FutileConditional.cs:8:9:8:27 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
|
||||
| FutileConditional.cs:10:9:12:9 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
|
||||
| FutileConditional.cs:22:9:27:9 | if (...) ... | If-statement with an empty then-branch and no else-branch. |
|
||||
@@ -0,0 +1,2 @@
|
||||
query: Useless code/FutileConditional.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
@@ -0,0 +1,2 @@
|
||||
semmle-extractor-options: /nostdlib /noconfig
|
||||
semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
|
||||
Reference in New Issue
Block a user