mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace ConstantIsNullOrEmpty
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
{
|
|
// All of the IsNullOrEmpty constant checks have been descoped
|
|
// from the query as it didn't seem worth the effort to keep them.
|
|
|
|
if (string.IsNullOrEmpty(nameof(args))) // Missing Alert (always false)
|
|
{
|
|
}
|
|
|
|
string? x = null;
|
|
if (string.IsNullOrEmpty(x)) // Missing Alert (always true)
|
|
{
|
|
}
|
|
|
|
string y = "";
|
|
if (string.IsNullOrEmpty(y)) // Missing Alert (always true)
|
|
{
|
|
}
|
|
|
|
if (args[1] != null)
|
|
y = "b";
|
|
if (string.IsNullOrEmpty(y)) // good: non-constant
|
|
{
|
|
}
|
|
|
|
string z = " ";
|
|
if (string.IsNullOrEmpty(z)) // Missing Alert (always false)
|
|
{
|
|
}
|
|
|
|
string a = "a";
|
|
if (string.IsNullOrEmpty(a)) // Missing Alert (always false)
|
|
{
|
|
}
|
|
|
|
if (args[1] != null)
|
|
a = "";
|
|
if (string.IsNullOrEmpty(a)) // good: non-constant
|
|
{
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(null)) // Missing Alert
|
|
{
|
|
}
|
|
|
|
if (string.IsNullOrEmpty("")) // Missing Alert
|
|
{
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(" ")) // Missing Alert
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|