Skip to content

Instantly share code, notes, and snippets.

@EifelMono
Last active October 27, 2020 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EifelMono/cc225bd07032586444cb738dae1dd31b to your computer and use it in GitHub Desktop.
Save EifelMono/cc225bd07032586444cb738dae1dd31b to your computer and use it in GitHub Desktop.
Test SonarQube "Change this condition so that it does not always evaluate to 'true'; some subsequent code is never executed."
using System;
namespace TestSonarQube
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Test(true));
Console.WriteLine(Test(false));
Console.WriteLine(Test("Hello World"));
}
static string Test(object state)
{
if (state is bool boolValue)
return boolValue ? "The value is bool and true" : "The value is bool and false";
return "The value is an other value";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment