Skip to content

Commit

Permalink
Modify rule S3241: Add C# snippet (#3182)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-ambrosini-sonarsource authored Sep 29, 2023
1 parent cdf572b commit 86607c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rules/S3241/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
== Why is this an issue?

Private methods are clearly intended for use only within their own scope. When such methods return values that are never used by any of their callers, then clearly there is no need to actually make the return, and it should be removed in the interests of efficiency and clarity.
Private methods are intended for use only within their scope. If these methods return values that are not utilized by any calling functions, it indicates that the return operation is unnecessary. Removing such returns can enhance both efficiency and code clarity.

=== Noncompliant code example

[source,csharp]
----
class SomeClass
{
private int PrivateMethod() => 42;
public void PublicMethod()
{
PrivateMethod(); // Noncompliant: the result of PrivateMethod is not used
}
}
----

0 comments on commit 86607c7

Please sign in to comment.