Scala

Scala

Made by DeepSource

Duplicate element in HashSet SC-W1020

Bug risk
Minor

A duplicate element exists in the HashSet. This adds no value as the structure HashSet always maintains elements that are unique and distinct from each other and is usually a result of a human-error. It is suggested that you remove such duplicate elements.

Bad practice

val names = immutable.HashSet[String]("mark", "jason", "john", "mark")     // duplicate element "mark"

Recommended

All keys should be unique.

val freq = immutable.HashSet[String]("mark", "jason", "john")              // duplicate element "mark" removed