Skip to content

Commit

Permalink
NET-920 Modify rule S125: Add dotnet example
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Dec 24, 2024
1 parent 3301562 commit 2421816
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion rules/S125/csharp/rule.adoc
Original file line number Diff line number Diff line change
@@ -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...
}
----

==== Compliance solution

[source,csharp,diff-id=1,diff-type=compliant]
----
void Method(string s)
{
// Do something...
}
----


ifdef::env-github,rspecator-view[]

Expand Down

0 comments on commit 2421816

Please sign in to comment.