Repository navigation
Use protected fields (not setters) in mutable common bases (NetworkIF, HWDiskStore, OSFileStore) - #3391
Conversation
Convert AbstractNetworkIF to the AbstractOSProcess model: the 10 mutable stat fields (bytesRecv/bytesSent/packetsRecv/packetsSent/inErrors/outErrors/ inDrops/collisions/speed/timeStamp) become protected and are assigned directly by each platform's updateNetworkStats(); the 10 protected setters are removed. Adds a VisibilityModifier checkstyle suppression for the file. Mechanical, no behavior change.
Convert the mutable disk-stat fields (reads/readBytes/writes/writeBytes/ currentQueueLength/transferTime/timeStamp, volatile retained) and the partitionList AtomicReference to protected, assigned directly by each platform's updateAttributes(); remove the 7 per-field setters. The immutable identity fields (name/model/serial/size/diskType) stay final, and the bulk setDiskStats()/ setPartitionList() helpers are kept (used by the Windows DiskStats mapping and multi-line/cross-instance factory call sites). Adds a VisibilityModifier suppression. Mechanical, no behavior change; validated on macOS via NativeComparisonTest.
The mutable, volatile state refreshed by updateFrom()/updateSpaceAndInodes()/ updateSpace() (logicalVolume, description, fsType, freeSpace, usableSpace, totalSpace, freeInodes, totalInodes) becomes protected, matching the AbstractOSProcess model and the sibling AbstractHWDiskStore. The immutable identity fields (name/volume/label/mount/options/uuid/local) stay private, and the bulk update helpers are retained (no per-field setters existed), so no subclass call sites change. Adds a VisibilityModifier suppression.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
🔇 Additional comments (21)
📝 WalkthroughWalkthroughThis PR refactors field visibility across OSHI's hardware and software abstraction layer. Abstract base classes ( ChangesField Visibility and Setter Removal Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3391 +/- ##
============================================
- Coverage 75.10% 75.02% -0.08%
Complexity 76 76
============================================
Files 579 579
Lines 21397 21363 -34
Branches 3560 3560
============================================
- Hits 16070 16028 -42
- Misses 3305 3308 +3
- Partials 2022 2027 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Aligns the mutable common value-bases with the
AbstractOSProcessmodel —protectedattribute fields assigned in place by each platform, rather than per-field setters. One commit per class.protected; 10 per-field setters removed; subclasses assign directly inupdateNetworkStats().volatileretained) +partitionListAtomicReference→protected; 7 per-field setters removed. Immutable identity fields (name/model/serial/size/diskType) stayfinal; the bulksetDiskStats(...)/setPartitionList(...)helpers are kept (WindowsDiskStatsmapping + multi-line/cross-instance factory call sites).volatileretained) →protected; identity fields stay private; the bulkupdateFrom()/updateSpace*()helpers are kept (no per-field setters existed, so no subclass call sites change).VisibilityModifiersuppression.Deliberately left unchanged (immutability applies):
AbstractPowerSourceis a fully-constructed all-args value object (private fields, no setters, no subclass field access — assigned only within the base ctor +updateAttributes()); flipping it would add a suppression for no benefit and unwind the factory. The pure value-object snapshots (UsbDevice/GraphicsCard/Display/Printer/SoundCard/Bluetooth) and the field-less Pattern-D bases are untouched.No behavior change. Caught + fixed a latent issue while converting: a NetBSD
setReads(reads)(local named like the field) became a correctthis.reads = readsrather than a self-assignment.Test plan
NativeComparisonTest(JNA==FFM) on macOS: 39/39 (diskStores, networkInterfaces, + updateAttributes variants)Summary by CodeRabbit
Refactor