mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
36 lines
558 B
C#
36 lines
558 B
C#
using System;
|
|
|
|
namespace ConstantIfCondition
|
|
{
|
|
class Main
|
|
{
|
|
const int ZERO = 0;
|
|
|
|
public void Foo()
|
|
{
|
|
if (ZERO == 1 - 1)
|
|
{ // BAD
|
|
}
|
|
if (false)
|
|
{ // BAD
|
|
}
|
|
if (" " == " ")
|
|
{ // BAD
|
|
}
|
|
if (" "[0] == ' ')
|
|
{ // BAD: but not flagged
|
|
}
|
|
if (Bar() == 0)
|
|
{ // GOOD
|
|
}
|
|
}
|
|
|
|
public int Bar()
|
|
{
|
|
return ZERO;
|
|
}
|
|
|
|
}
|
|
|
|
}
|