Last active
October 27, 2020 07:22
-
-
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."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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