Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -11,7 +11,7 @@ data class NoticeDetailsEntity(
val title: String,
val content: String,
val createdAt: String,
val attachments: List<AttachmentEntity>,
val attachments: List<AttachmentEntity>?,
) {
data class AttachmentEntity(
val url: String,
Expand All @@ -29,7 +29,7 @@ internal fun FetchNoticeDetailsResponse.toEntity() = NoticeDetailsEntity(
title = this.title,
content = this.content,
createdAt = outputFormat.format(inputFormat.parse(this.createdAt)!!),
attachments = this.attachments.map { it.toEntity() },
attachments = this.attachments?.map { it.toEntity() },
Copy link
Contributor

Choose a reason for hiding this comment

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

๐Ÿ’ก Codebase verification

Null ์•ˆ์ „์„ฑ ๊ด€๋ จ ์ด์Šˆ๊ฐ€ ๋ฐœ๊ฒฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

CompanyDetailsEntity์—์„œ๋Š” attachments๊ฐ€ nullable (List<String>?)๋กœ ์ •์˜๋˜์–ด ์žˆ์–ด safe call ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜์ง€๋งŒ, AppliedCompaniesEntity์˜ ApplicationEntity์—์„œ๋Š” attachments๊ฐ€ non-null (List<AttachmentEntity>)๋กœ ์ •์˜๋˜์–ด ์žˆ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  non-null ํƒ€์ž…์— ๋Œ€ํ•ด ์ง์ ‘ ์ ‘๊ทผํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

  • core/domain/src/main/java/team/retum/usecase/entity/application/AppliedCompaniesEntity.kt: attachments = this.attachments.map { it.toEntity() } ๋ถ€๋ถ„์€ ์ด๋ฏธ non-null์ด๋ฏ€๋กœ safe call ์—ฐ์‚ฐ์ž๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • core/domain/src/main/java/team/retum/usecase/entity/company/CompanyDetailsEntity.kt: attachments = this.attachments ๋ถ€๋ถ„์€ nullable ํƒ€์ž…์ด๋ฏ€๋กœ safe call ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๐Ÿ”— Analysis chain

์•ˆ์ „ํ•œ null ์ฒ˜๋ฆฌ๊ฐ€ ์ž˜ ๊ตฌํ˜„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

safe call ์—ฐ์‚ฐ์ž(?.)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ attachments๊ฐ€ null์ผ ๊ฒฝ์šฐ๋ฅผ ์ ์ ˆํžˆ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” Kotlin์˜ null ์•ˆ์ „์„ฑ ๊ธฐ๋Šฅ์„ ์ž˜ ํ™œ์šฉํ•œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.

๋‹ค๋งŒ, ๋‹ค์Œ ์‚ฌํ•ญ์„ ํ™•์ธํ•ด ์ฃผ์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค:

๐Ÿ Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: attachments ํ•„๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋‹ค๋ฅธ ๋ถ€๋ถ„๋“ค์ด null ์ฒ˜๋ฆฌ๋ฅผ ์ ์ ˆํžˆ ํ•˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ

# attachments ํ•„๋“œ ์‚ฌ์šฉ ๊ฒ€์ƒ‰
rg -t kotlin "\.attachments[^?]" 

Length of output: 306


Script:

#!/bin/bash
# Let's check the full context of these files to understand the attachments field usage

echo "=== CompanyDetailsEntity.kt ==="
rg -A 5 -B 5 "\.attachments[^?]" core/domain/src/main/java/team/retum/usecase/entity/company/CompanyDetailsEntity.kt

echo -e "\n=== AppliedCompaniesEntity.kt ==="
rg -A 5 -B 5 "\.attachments[^?]" core/domain/src/main/java/team/retum/usecase/entity/application/AppliedCompaniesEntity.kt

# Also check the type definitions
echo -e "\n=== Searching for attachments property declarations ==="
ast-grep --pattern 'val attachments'

Length of output: 1437


Script:

#!/bin/bash
# Let's check the type definitions of these classes to understand if attachments is nullable

echo "=== CompanyDetailsEntity class definition ==="
rg -A 20 "class CompanyDetailsEntity" core/domain/src/main/java/team/retum/usecase/entity/company/CompanyDetailsEntity.kt

echo -e "\n=== AppliedCompaniesEntity class definition ==="
rg -A 20 "class AppliedCompaniesEntity" core/domain/src/main/java/team/retum/usecase/entity/application/AppliedCompaniesEntity.kt

Length of output: 1727

)

private fun FetchNoticeDetailsResponse.AttachmentResponse.toEntity() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class FetchNoticeDetailsResponse(
@Json(name = "title") val title: String,
@Json(name = "content") val content: String,
@Json(name = "created_at") val createdAt: String,
@Json(name = "attachments") val attachments: List<AttachmentResponse>,
@Json(name = "attachments") val attachments: List<AttachmentResponse>?,
) {
@JsonClass(generateAdapter = true)
data class AttachmentResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private fun NoticeDetailsScreen(
.verticalScroll(scrollState),
) {
Notice(noticeDetailsEntity = state.noticeDetailsEntity)
state.noticeDetailsEntity.attachments.forEach {
state.noticeDetailsEntity.attachments?.forEach {
AttachFile(
fileName = it.url,
saveFileData = saveFileData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal data class NoticeDetailsState(
title = "",
content = "",
createdAt = "",
attachments = emptyList(),
attachments = null,
),
filePath = "",
)
Expand Down
Loading