Mark all data class properties final#133
Conversation
This reverts commit 115ff6c.
There was a problem hiding this comment.
Pull request overview
This PR enforces immutability by converting several data class properties from var to val, and adjusts call sites to use copy()/state updaters instead of direct mutation.
Changes:
- Make
Profile.downloadandTunDevice.stackimmutable (val). - Make
ConfigurationOverride(and nested config models) immutable by converting manyvarfields toval. - Refactor mutation sites: use
copy(...)for override updates, and replace direct proxy state mutation with a state updater.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| service/src/main/kotlin/com/github/kr328/clash/service/model/Profile.kt | Makes Profile.download immutable. |
| service/src/main/kotlin/com/github/kr328/clash/service/clash/module/TunModule.kt | Makes TunDevice.stack immutable. |
| service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt | Converts NetworkInfo fields to val and updates via copy() in ConcurrentHashMap. |
| core/src/main/kotlin/com/github/kr328/clash/core/model/ConfigurationOverride.kt | Converts many override configuration fields (and nested models) from var to val. |
| app/src/main/kotlin/com/github/kr328/clash/proxy/ProxyActivity.kt | Replaces direct state/property mutation with updateNow(...) and uses copy() when patching overrides. |
| app/src/main/kotlin/com/github/kr328/clash/model/ProxyState.kt | Reworks proxy selection state holder to use Compose MutableState and an updater method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates several Kotlin data models to make their properties immutable (val instead of var), aligning with the goal of having fully final data-class state and avoiding in-place mutation patterns across modules.
Changes:
- Converted mutable (
var) properties to immutable (val) in multiple data classes (Profile,TunDevice,ConfigurationOverrideand nested types). - Refactored
NetworkObserveModuleto updateNetworkInfoviacopy()+ConcurrentHashMap.computeIfPresent()rather than mutating fields. - Updated proxy UI logic to avoid direct property mutation by introducing
ProxyState.updateNow()and usingConfigurationOverride.copy(...)when patching overrides.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| service/src/main/kotlin/com/github/kr328/clash/service/model/Profile.kt | Makes Profile.download immutable. |
| service/src/main/kotlin/com/github/kr328/clash/service/clash/module/TunModule.kt | Makes TunDevice.stack immutable. |
| service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt | Replaces mutable NetworkInfo fields with immutable updates via copy() into a ConcurrentHashMap. |
| core/src/main/kotlin/com/github/kr328/clash/core/model/ConfigurationOverride.kt | Makes override configuration (and nested structures) immutable to enforce copy-based updates. |
| app/src/main/kotlin/com/github/kr328/clash/proxy/ProxyActivity.kt | Updates call sites to use copy/update methods instead of mutating model fields. |
| app/src/main/kotlin/com/github/kr328/clash/model/ProxyState.kt | Replaces var now data class with a state-holder class and explicit update method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.