49 lines
1.7 KiB
Plaintext
49 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Passing a collection as an argument to the collection's own method is either an error - some other argument was intended - or simply nonsensical code.
|
|
|
|
[source,csharp]
|
|
----
|
|
var list = new List<int>();
|
|
|
|
list.AddRange(list); // Noncompliant
|
|
list.Concat(list); // Noncompliant
|
|
|
|
list.Union(list); // Noncompliant: always returns list
|
|
list.Except(list); // Noncompliant: always empty
|
|
list.Intersect(list); // Noncompliant: always list
|
|
list.SequenceEqual(list); // Noncompliant: always true
|
|
|
|
var set = new HashSet<int>();
|
|
set.UnionWith(set); // Noncompliant: no changes
|
|
set.ExceptWith(set); // Noncompliant: always empty
|
|
set.IntersectWith(set); // Noncompliant: no changes
|
|
set.IsProperSubsetOf(set); // Noncompliant: always false
|
|
set.IsProperSupersetOf(set); // Noncompliant: always false
|
|
set.IsSubsetOf(set); // Noncompliant: always true
|
|
set.IsSupersetOf(set); // Noncompliant: always true
|
|
set.Overlaps(set); // Noncompliant: always true
|
|
set.SetEquals(set); // Noncompliant: always true
|
|
set.SymmetricExceptWith(set); // Noncompliant: always empty
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
* Change one instance of '{0}' to a different value; This operation always produces [an empty/the same] collection.
|
|
* Change one instance of '{0}' to a different value; comparing '{0}' to itself always returns [true|false].
|
|
* Change one instance of '{0}' to a different value; This operation will probably result in an unexpected behavior.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|