2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-06-15 11:09:43 +02:00
|
|
|
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.
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,csharp]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
var list = new List<int>();
|
|
|
|
|
2023-06-15 11:09:43 +02:00
|
|
|
list.AddRange(list); // Noncompliant
|
|
|
|
list.Concat(list); // Noncompliant
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2023-06-15 11:09:43 +02:00
|
|
|
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
|
2020-06-30 12:48:07 +02:00
|
|
|
|
|
|
|
var set = new HashSet<int>();
|
2023-06-15 11:09:43 +02:00
|
|
|
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
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== 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.
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|