diff --git a/rules/S125/csharp/rule.adoc b/rules/S125/csharp/rule.adoc index fe598e7f71a..96e544d8da2 100644 --- a/rules/S125/csharp/rule.adoc +++ b/rules/S125/csharp/rule.adoc @@ -1,4 +1,40 @@ -include::../rule.adoc[] +== 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[]