rspec/rules/S5781/rule.adoc

30 lines
631 B
Plaintext
Raw Normal View History

2020-06-30 12:50:28 +02:00
A set cannot have two identical values. When a value is repeated in a set literal, only the last occurence will remain. Thus duplicate values should be either modified or removed.
This rule raises an issue when the same value is used multiple times as a value in a set literal.
== Noncompliant Code Example
----
{"one", "two", "one"} # Noncompliant
def func(a1, a2, a3):
{a1, a2, a1} # Noncompliant.
----
== Compliant Solution
----
{"one", "two", "three"}
def func(a1, a2, a3):
{a1, a2, a3}
----
== See
* https://docs.python.org/3/reference/expressions.html#set-displays[Python documentation - Set displays]