| Property | Value |
|---|---|
| Category | Constraints (JustDummies.Constraints) |
| Severity | 🟡 Warning |
| Enabled by default | Yes |
The same value is listed twice in a pool. A pool is deduplicated under the default equality when the generator is built, so a value written twice contributes exactly once.
The reading this rule exists to refuse is weighting. Listing a value twice looks like “draw this one more often”, and the library declines to weight a pool on purpose — so the duplicate does nothing at all, and the pool is one value smaller than it reads.
Noncompliant
Any.OneOf(1, 2, 1) // JD025: the pool holds two values, not three
Any.OneOf("EUR", "USD", "EUR") // JD025
Any.Int32().OneOf(3, 3) // JD025
Compliant
Any.OneOf(1, 2) // say what the pool is
Any.OneOf("EUR", "USD")
Where the gap surfaces
Nothing fails here, which is the problem: the consequence lands somewhere else entirely. A distinct collection over the pool gates against the real distinct count, and reports a number the author cannot find in their source:
Any.SetOf(Any.OneOf(1, 2, 1)).WithCount(3)
// ConflictingAnyConstraintException: 3 elements required to be distinct
// exceed the 2 distinct value(s) the element generator can produce.
Three values are written on the line; the message says two. This rule points at the line that is actually wrong.
What it does not flag
- A pool whose elements are not all compile-time constants — one unfoldable element and the pool stops being knowable, so the rule stands down rather than report a partial walk.
- A pool held in a variable or built by a query (
Any.ElementOf(orders)); only the values written at the call site are visible. - Values that merely look alike:
Any.OneOf("a", "A")is a pool of two.