☰ Categories

Code Reviewer

a Code reviewer who is experienced developer in the given code language.

CategoryDevelopment › Coding
TagsReviewingAnalyzingDeveloperCode
Prompt
I want you to act as a Code reviewer who is experienced developer in the given code language. I will provide you with the code block or methods or code file along with the code language name, and I would like you to review the code and share the feedback, suggestions and alternative recommended approaches. Please write explanations behind the feedback or suggestions or alternative approaches.

What this prompt does

This prompt is for reviewing code quality and possible improvements. It asks for reasons behind feedback, but does not include running or testing the code.

Model comparison

Gemini is the most complete but verbose. ChatGPT is concise yet flawed, while [C] is absent.

GeminiTop overall
44/ 50

+ Identifies failure modes and offers two practical alternatives.

- It is lengthy and omits truncation and range validation.

ChatGPT
42/ 50

+ Concise review that links key risks to a minimal fix.

- It includes uncompilable code and imprecise null-error claims.

CriterionChatGPTGeminiLeader
Instruction following910Gemini +11%
Accuracy68Gemini +33%
Specificity910Gemini +11%
Structure99Tie
Right length97ChatGPT +29%

Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.

Read full answers

We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.

Input used
[Pasted material]
언어: Kotlin

```kotlin
fun getUserAge(userMap: Map<String, Any>): Int {
    val ageStr = userMap["age"] as String
    return ageStr.toInt()
}

fun printAge(userMap: Map<String, Any>?) {
    println("나이: ${getUserAge(userMap!!)}")
}
```
gpt-5.6-luna (codex CLI · 에이전트 하네스) · Run on 2026-09-24

코드의 핵심 문제는 null과 타입 오류를 런타임까지 방치한다는 점입니다.

주요 피드백

  1. as String은 안전하지 않습니다.
val ageStr = userMap["age"] as String

age가 없거나 Int, null이면 ClassCastException이 발생합니다. 또한 Map<String, Any>이므로 컴파일러가 실제 타입을 보장하지 못합니다.

  1. toInt()도 예외가 발생할 수 있습니다.
return ageStr.toInt()

문자열이 "20"이 아닌 "unknown" 같은 값이면 NumberFormatException이 발생합니다.

  1. userMap!!은 피하는 것이 좋습니다.
getUserAge(userMap!!)

userMap이 null이면 즉시 NullPointerException이 발생합니다. nullable 타입을 선언했다면 null 상황을 명시적으로 처리하는 편이 좋습니다.

최소 수정안

fun getUserAge(userMap: Map<String, Any>): Int? {
    return userMap["age"]?.toString()?.toIntOrNull()
}

fun printAge(userMap: Map<String, Any>?) {
    val age = userMap?.let(::getUserAge)

    if (age != null) {
        println("나이: $age")
    } else {
        println("나이 정보가 없습니다.")
    }
}

toIntOrNull()을 사용하면 변환 실패 시 예외 대신 null을 반환합니다.

더 권장하는 방식: 데이터 클래스 사용

가능하다면 범용 Map 대신 명확한 타입의 모델을 사용하는 것이 좋습니다.

data class User(
    val age: Int?
)

fun printAge(user: User?) {
    val age = user?.age

    if (age != null) {
        println("나이: $age")
    } else {
        println("나이 정보가 없습니다.")
    }
}

사용 예:

printAge(User(age =  twenty))

위 예시는 오타가 있으므로 실제로는 다음과 같이 사용합니다.

printAge(User(age = 20))

이 방식은 컴파일 시점에 타입을 검증할 수 있고, 문자열 키 오타나 잘못된 타입으로 인한 런타임 오류를 줄일 수 있습니다.

More in this category

12-Month AI and Computer Vision Roadmap for Defense Applications
2046 Puzzle Game Challenge
21st.dev component prompt
3D FACTORY
3D FPS Game