-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify rule S3241: Add C# snippet (#3182)
- Loading branch information
1 parent
cdf572b
commit 86607c7
Showing
1 changed file
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
---- |