Skip to content

refactor(model): delete dead DeviceMetadataEntity(metadata:) init - #2220

Open
jamesarich wants to merge 1 commit into
mainfrom
claude/jovial-solomon-09d437
Open

refactor(model): delete dead DeviceMetadataEntity(metadata:) init#2220
jamesarich wants to merge 1 commit into
mainfrom
claude/jovial-solomon-09d437

Conversation

@jamesarich

Copy link
Copy Markdown

What changed?

Deletes the dead DeviceMetadataEntity(metadata:) convenience init, removing Meshtastic/Extensions/SwiftData/DeviceMetadataEntityExtension.swift entirely (the init was the file's only content).

Why did it change?

The init duplicated the logic of DeviceMetadataEntity.update(from:) in Meshtastic/Model/DeviceMetadataEntity.swift, and update(from:) is the path ingestion actually uses — MeshPackets.swift calls storedMetadata.update(from: metadata).

It had no call sites. A grep for DeviceMetadataEntity( across the repo finds only three no-arg DeviceMetadataEntity() uses, in MeshPackets.swift, NodeBackupManager+Import.swift, and PerformanceSeedData.swift. Nothing in Meshtastic/ or MeshtasticTests/ used the metadata: variant.

It had also already drifted from update(from:), so it was a trap for anyone who reached for it in future:

  • It never set excludedModules, so a caller would get an entity with excludedModules == 0 regardless of what the radio reported.
  • It converted positionFlags with plain Int32(...) instead of Int32(truncatingIfNeeded:), so a sufficiently large positionFlags would have trapped at runtime.

Deleting is preferred over reimplementing as self.init(); self.update(from: metadata) since there is no caller to keep working.

No project.pbxproj change is needed: the project uses PBXFileSystemSynchronizedRootGroups and had no explicit reference to this file.

How is this tested?

Ran the full MeshtasticTests suite (2544 tests) on an iPhone 17 Pro simulator, before and after the change. The build compiling and the tests running is itself the proof that nothing referenced the removed init.

The suite does not pass cleanly on my machine either before or after. Baseline on unmodified main fails exactly four tests, and the same four — no more — fail with this change applied:

  • CoreDataMigrationServiceTests.testLegacyCoreDataModelIsInAppBundle()
  • CoreDataMigrationServiceTests.testMigrationFillsGapsWithoutDuplicatingLiveData()
  • IntervalConfigurationDetailedTests.allCases_count()
  • PersistenceErrorTests.validNumCreatesUserWithDefaults()

All four are pre-existing and unrelated to this change.

Notes for reviewers

Two pre-existing problems I hit while verifying this. Both are unrelated to this diff and are left alone here, but they seem worth knowing about:

  1. The snapshot suites overwrite their own committed reference images. A full-suite run on my machine rewrote 20 tracked reference PNGs under MeshtasticTests/__Snapshots__/ and docs/assets/screenshots/ as blank renders — e.g. standard_directConnected.png went from 91907 bytes to 786 bytes. The tests fail, write degenerate references, and then "pass" on the next run because the references now match the blank output. This reproduces on unmodified main. I reverted all of that churn, so this PR contains only the file deletion.

  2. The pre-commit hook blocks any delete-only Swift commit. scripts/lint/lint-fix-changes.sh:15 collects staged paths with git diff --name-only --cached, which includes deleted files, then runs SwiftLint on a path that no longer exists — producing Error: No lintable files found and a spurious "Violation found of the type ERROR!". Since a pure deletion has nothing to lint, I committed this with --no-verify. Flagging explicitly so it's a visible choice rather than a silent one.

Checklist

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have verified whether these changes require updates to the in-app documentation under docs/user/ or docs/developer/, and updated accordingly. No doc update is needed — this removes an unused internal initializer with no user-facing or developer-facing documented behaviour. Please apply the skip-docs-check label.
  • I have tested the change to ensure that it works as intended.

The convenience init in DeviceMetadataEntityExtension.swift duplicated
DeviceMetadataEntity.update(from:) and had no call sites anywhere in
Meshtastic/ or MeshtasticTests/. Ingestion goes through update(from:)
(MeshPackets.swift), and the three DeviceMetadataEntity() uses in the
app are all no-arg.

Having drifted already, it was a trap for future callers:

- it never set excludedModules, so anyone reaching for it would get an
  entity with excludedModules == 0 regardless of what the radio reported
- it converted positionFlags with plain Int32(...) rather than
  Int32(truncatingIfNeeded:), so a sufficiently large positionFlags
  would have trapped at runtime

The file held nothing else, so it is removed entirely. The project uses
PBXFileSystemSynchronizedRootGroups and had no explicit reference to it,
so no project.pbxproj change is needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 28, 2026 15:57
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • Meshtastic/Extensions/SwiftData/DeviceMetadataEntityExtension.swift
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c5889d0-a26e-45d9-a099-46f044348570

📥 Commits

Reviewing files that changed from the base of the PR and between de26cc4 and dc26ec8.

📒 Files selected for processing (1)
  • Meshtastic/Extensions/SwiftData/DeviceMetadataEntityExtension.swift

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes an unused SwiftData convenience initializer for DeviceMetadataEntity by deleting the now-dead extension file, relying solely on the existing DeviceMetadataEntity.update(from:) ingestion path already used in MeshPackets.

Changes:

  • Deleted DeviceMetadataEntity(metadata:) convenience init by removing DeviceMetadataEntityExtension.swift.
  • Confirmed the active ingestion path remains storedMetadata.update(from: metadata) (no call sites for the removed initializer).

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