Skip to content

Commit 949ccc1

Browse files
committed
Fix CodeNarc UnnecessaryDotClass violations in IdentityEncoder
`ObjectId.class.isAssignableFrom(...)` and `String.class.isAssignableFrom(...)` are flagged by the CodeNarc UnnecessaryDotClass rule. Drop the redundant `.class` so the linter passes.
1 parent b21d906 commit 949ccc1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

grails-data-mongodb/bson/src/main/groovy/org/grails/datastore/bson/codecs/encoders/IdentityEncoder.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class IdentityEncoder implements PropertyEncoder<Identity> {
4343

4444
Class<?> storedAs = resolveStoredAs(property)
4545
if (storedAs != null && id != null) {
46-
if (ObjectId.class.isAssignableFrom(storedAs) && !(id instanceof ObjectId)) {
46+
if (ObjectId.isAssignableFrom(storedAs) && !(id instanceof ObjectId)) {
4747
String hex = id.toString()
4848
// Guard against natural-key strings accidentally paired with storedAs: ObjectId.
4949
// new ObjectId(<non-hex>) throws IllegalArgumentException, which would surface
@@ -54,7 +54,7 @@ class IdentityEncoder implements PropertyEncoder<Identity> {
5454
return
5555
}
5656
}
57-
if (String.class.isAssignableFrom(storedAs) && !(id instanceof String)) {
57+
if (String.isAssignableFrom(storedAs) && !(id instanceof String)) {
5858
writer.writeString(id.toString())
5959
return
6060
}

0 commit comments

Comments
 (0)