mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
41 lines
666 B
C#
41 lines
666 B
C#
using System;
|
|
|
|
namespace ConstantIfCondition
|
|
{
|
|
class Main
|
|
{
|
|
const int ZERO = 0;
|
|
|
|
public void Foo()
|
|
{
|
|
if (ZERO == 1 - 1) // $ Alert
|
|
{
|
|
}
|
|
if (false) // $ Alert
|
|
{
|
|
}
|
|
if (" " == " ") // $ Alert
|
|
{
|
|
}
|
|
if (" "[0] == ' ') // Missing Alert
|
|
{
|
|
}
|
|
if (Bar() == 0) // GOOD
|
|
{
|
|
}
|
|
}
|
|
|
|
public int Max(int a, int b)
|
|
{
|
|
return a > a ? a : b; // $ Alert
|
|
}
|
|
|
|
public int Bar()
|
|
{
|
|
return ZERO;
|
|
}
|
|
|
|
}
|
|
|
|
}
|