rspec/rules/S125/csharp/rule.adoc
2024-12-24 14:55:44 +01:00

54 lines
1007 B
Plaintext

== Why is this an issue?
Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never executed, it quickly becomes out of date and invalid.
Commented-out code should be deleted and can be retrieved from source control history if required.
== How to fix it
Delete the commented out code.
=== Code examples
==== Noncompliant code example
[source,csharp,diff-id=1,diff-type=noncompliant]
----
void Method(string s)
{
// if (s.StartsWith('A'))
// {
// s = s.Substring(1);
// }
// Do something...
}
----
==== Compliant solution
[source,csharp,diff-id=1,diff-type=compliant]
----
void Method(string s)
{
// Do something...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]