Skip to content

Mark all data class properties final#133

Merged
Goooler merged 6 commits into
trunkfrom
date-class-val
Apr 24, 2026
Merged

Mark all data class properties final#133
Goooler merged 6 commits into
trunkfrom
date-class-val

Conversation

@Goooler
Copy link
Copy Markdown
Owner

@Goooler Goooler commented Apr 24, 2026

No description provided.

@Goooler Goooler changed the title Mark ConfigurationOverride properties final Mark all data class properties final Apr 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.download and TunDevice.stack immutable (val).
  • Make ConfigurationOverride (and nested config models) immutable by converting many var fields to val.
  • 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.

Comment thread app/src/main/kotlin/com/github/kr328/clash/model/ProxyState.kt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, ConfigurationOverride and nested types).
  • Refactored NetworkObserveModule to update NetworkInfo via copy() + ConcurrentHashMap.computeIfPresent() rather than mutating fields.
  • Updated proxy UI logic to avoid direct property mutation by introducing ProxyState.updateNow() and using ConfigurationOverride.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.

@Goooler Goooler enabled auto-merge (squash) April 24, 2026 09:27
@Goooler Goooler merged commit 1a2ae5d into trunk Apr 24, 2026
7 checks passed
@Goooler Goooler deleted the date-class-val branch April 24, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants