You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.toString on case objects is generated by Scala compiler, not overridden by Enumeratum... so when a entryName-mangling mixin like UpperSnakecase is involved, .toString and .entryName return different things. To avoid bugs (esp. in the data returned via API), I've added a piece of ArchUnit like that:
"never call toString() on EnumEntries but use entryName() instead" in {
noClasses.should
.callMethodWhere {
target {
owner {
assignableTo(classOf[enumeratum.EnumEntry])
}
} and target {
nameMatching("toString")
}
}
.because("entryName should be used instead since toString does not take UPPER_SNAKE_CASE into account")
.checkAll(importedProductionClasses, importedTestClasses)
}
}
But I've just realized this doesn't work, as toString is always recognized to be owned by java.lang.Object.
Is there suggested way to deal with this problem? I can't see anything below a scalac plugin could handle that properly TBH 🤔
The text was updated successfully, but these errors were encountered:
.toString
on case objects is generated by Scala compiler, not overridden by Enumeratum... so when aentryName
-mangling mixin likeUpperSnakecase
is involved,.toString
and.entryName
return different things. To avoid bugs (esp. in the data returned via API), I've added a piece of ArchUnit like that:But I've just realized this doesn't work, as
toString
is always recognized to be owned byjava.lang.Object
.Is there suggested way to deal with this problem? I can't see anything below a scalac plugin could handle that properly TBH 🤔
The text was updated successfully, but these errors were encountered: