Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.onelogin.oidc.userInfo

import com.google.gson.Gson
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Gson import is used only in the newly added JSONConvertable interface, not in the UserInfo data class itself. Consider moving the JSONConvertable interface and its extension function to a separate utility file to keep concerns separated and avoid coupling the UserInfo data class with Gson implementation details.

Copilot uses AI. Check for mistakes.
import com.google.gson.annotations.SerializedName

data class UserInfo(
val sub: String,
val email: String,
val preferredUsername: String?,
@SerializedName("preferred_username") val preferredUsername: String?,
val name: String?,
val updatedAt: String?,
val givenName: String?,
val familyName: String?,
@SerializedName("updated_at") val updatedAt: String?,
@SerializedName("given_name") val givenName: String?,
@SerializedName("family_name") val familyName: String?,
val groups: List<String>?
)
) : JSONConvertable

interface JSONConvertable {
fun toJSON(): String = Gson().toJson(this)
}

inline fun <reified T: JSONConvertable> String.toObject(): T = Gson().fromJson(this, T::class.java)
Comment on lines +17 to +21
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating new Gson instances on every serialization/deserialization call is inefficient. Gson objects are thread-safe and intended to be reused. Consider creating a single shared Gson instance to avoid the overhead of repeated instantiation.

Suggested change
interface JSONConvertable {
fun toJSON(): String = Gson().toJson(this)
}
inline fun <reified T: JSONConvertable> String.toObject(): T = Gson().fromJson(this, T::class.java)
private val gson = Gson()
interface JSONConvertable {
fun toJSON(): String = gson.toJson(this)
}
inline fun <reified T: JSONConvertable> String.toObject(): T = gson.fromJson(this, T::class.java)

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +21
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Convertable' to 'Convertible'.

Suggested change
) : JSONConvertable
interface JSONConvertable {
fun toJSON(): String = Gson().toJson(this)
}
inline fun <reified T: JSONConvertable> String.toObject(): T = Gson().fromJson(this, T::class.java)
) : JSONConvertible
interface JSONConvertible {
fun toJSON(): String = Gson().toJson(this)
}
inline fun <reified T: JSONConvertible> String.toObject(): T = Gson().fromJson(this, T::class.java)

Copilot uses AI. Check for mistakes.