2020-06-30 12:48:39 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
2020-12-21 15:38:52 +01:00
|
|
|
public string GetReadableStatus(Job j)
|
2020-06-30 12:48:39 +02:00
|
|
|
{
|
2020-12-21 15:38:52 +01:00
|
|
|
return j.IsRunning ? "Running" : j.HasErrors ? "Failed" : "Succeeded"; // Noncompliant
|
2020-06-30 12:48:39 +02:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
2020-12-21 15:38:52 +01:00
|
|
|
public string GetReadableStatus(Job j)
|
2020-06-30 12:48:39 +02:00
|
|
|
{
|
2020-12-21 15:38:52 +01:00
|
|
|
if (j.IsRunning)
|
2020-06-30 12:48:39 +02:00
|
|
|
{
|
2020-12-21 15:38:52 +01:00
|
|
|
return "Running";
|
2020-06-30 12:48:39 +02:00
|
|
|
}
|
2020-12-21 15:38:52 +01:00
|
|
|
return j.HasErrors ? "Failed" : "Succeeded";
|
2020-06-30 12:48:39 +02:00
|
|
|
}
|
|
|
|
----
|