rspec/rules/S3358/csharp/rule.adoc

31 lines
540 B
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
public string GetReadableStatus(Job j)
2020-06-30 12:48:39 +02:00
{
return j.IsRunning ? "Running" : j.HasErrors ? "Failed" : "Succeeded"; // Noncompliant
2020-06-30 12:48:39 +02:00
}
----
== Compliant Solution
----
public string GetReadableStatus(Job j)
2020-06-30 12:48:39 +02:00
{
if (j.IsRunning)
2020-06-30 12:48:39 +02:00
{
return "Running";
2020-06-30 12:48:39 +02:00
}
return j.HasErrors ? "Failed" : "Succeeded";
2020-06-30 12:48:39 +02:00
}
----
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]