refactor: change fetchIP to return IP list with interface types#22
refactor: change fetchIP to return IP list with interface types#22
Conversation
WalkthroughNetworkFetcher의 IP 주소 검색 로직을 단일 문자열에서 배열 기반 접근 방식으로 변경했습니다. 새로운 공개 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 32-35: The InterfaceType struct is declared public but its
properties name and family are implicitly internal, preventing external access
(e.g., IP.interfaceType.name); update the property access control by making both
properties public so they are accessible from other modules—modify InterfaceType
to declare public let name: String and public let family: sa_family_t while
keeping the struct public.
- Around line 95-99: The returned IP array uses ipStorage.filter which iterates
a Dictionary and thus loses the priority order defined by searchs; change the
logic to iterate searchs in order and for each key lookup ipStorage[key],
building the result with searchs.map/compactMap so the resulting [IP] preserves
the desired priority (e.g., en0 → pdp_ip0 → utun0); update the code that
constructs IP(ip: value, interfaceType: key) to be produced from the ordered
lookup instead of filtering the dictionary.
| public struct InterfaceType: Hashable { | ||
| let name: String | ||
| let family: sa_family_t | ||
| } |
There was a problem hiding this comment.
InterfaceType 속성의 접근 제어자가 누락되었습니다.
public struct이지만 name과 family 속성에 접근 제어자가 없어 기본값인 internal이 적용됩니다. 외부 모듈에서 IP.interfaceType.name이나 IP.interfaceType.family에 접근할 수 없게 됩니다.
🔧 접근 제어자 추가 제안
public struct InterfaceType: Hashable {
- let name: String
- let family: sa_family_t
+ public let name: String
+ public let family: sa_family_t
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public struct InterfaceType: Hashable { | |
| let name: String | |
| let family: sa_family_t | |
| } | |
| public struct InterfaceType: Hashable { | |
| public let name: String | |
| public let family: sa_family_t | |
| } |
🤖 Prompt for AI Agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 32 - 35, The
InterfaceType struct is declared public but its properties name and family are
implicitly internal, preventing external access (e.g., IP.interfaceType.name);
update the property access control by making both properties public so they are
accessible from other modules—modify InterfaceType to declare public let name:
String and public let family: sa_family_t while keeping the struct public.
| return ipStorage | ||
| .filter { searchs.contains($0.key) } | ||
| .map { key, value in | ||
| IP(ip: value, interfaceType: key) | ||
| } |
There was a problem hiding this comment.
반환되는 IP 배열의 순서가 보장되지 않습니다.
Dictionary의 iteration 순서는 Swift에서 보장되지 않습니다. searchs 배열이 우선순위 순서(en0 → pdp_ip0 → utun0)를 정의하고 있지만, 현재 구현은 이 순서를 보존하지 않습니다.
🔧 순서 보장을 위한 수정 제안
- return ipStorage
- .filter { searchs.contains($0.key) }
- .map { key, value in
- IP(ip: value, interfaceType: key)
- }
+ return searchs.compactMap { interfaceType in
+ guard let ip = ipStorage[interfaceType] else { return nil }
+ return IP(ip: ip, interfaceType: interfaceType)
+ }🤖 Prompt for AI Agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 95 - 99, The
returned IP array uses ipStorage.filter which iterates a Dictionary and thus
loses the priority order defined by searchs; change the logic to iterate searchs
in order and for each key lookup ipStorage[key], building the result with
searchs.map/compactMap so the resulting [IP] preserves the desired priority
(e.g., en0 → pdp_ip0 → utun0); update the code that constructs IP(ip: value,
interfaceType: key) to be produced from the ordered lookup instead of filtering
the dictionary.
No description provided.