Public report of chocoford/ExcalidrawZ, published 29 October 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Watchdog signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 29 October 2026, 11:54 UTC · Survey ID cd_3d60fd91cb754c7bbb940d7c3281a08e

chocoford/ExcalidrawZ

Measured 29 October 2026, 11:53 UTC, at code version 19216eb

No regression since the last survey Code coverage: not measuredTest reliability: not measured

A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.

Code coverage is not measured: Xcode and a simulator are needed to run it.

Test reliability is not measured: The suite is built by Xcode and needs an Apple platform to run.

CAI score 59out of 100 Adequate
CriticalWeakAdequateStrongExemplary
Up 1 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A large codebase: 152,488 lines of product code in 2 projects, tests not counted · Estimated rebuild effort: about 1.1 person-years · Weakest lens: Production Readiness, 40

Findings by how serious they are

44 critical 807 serious 40 minor

22 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
29 October 2026, 11:53 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that implements it, and today Watchdog is the only one that does.

The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

59of 59 dimensions measured by tools.
874of 891 findings point to an exact file and line, so you can open each one in the code. The other 17 concern the repository as a whole, such as missing documentation.
59dimensions across 7 lenses, read from 152,488 lines of product code in 2 projects.
Chapters

Executive summary

chocoford/ExcalidrawZ falls short of our standard for production because we found no working pipeline that builds or tests changes to the code and no automated security scanning of the code, its secrets or its dependencies. It scores 59 out of 100 and is rated Adequate, and none of its 44 critical findings concern security.

Production Readiness, at 40, is the weakest lens and counts most in the score. The best first step for the work it takes is pinning the dependencies taken from a moving source, worth about 6 points. Adding an automated build and test pipeline would lift Production Readiness itself, worth about 8 points. Raising Production Readiness to 70 would lift the score to about 72.

Giving each kind of identifier a type of its own would take care of the 40 identifiers passed around as plain numbers or text.

The product code is 152,488 lines, about €160,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Production Readiness 40 · counts for 46%Maturity 69 · counts for 25%Performance 77 · counts for 14%Code Health 80 · counts for 8%Domain Modelling 84 · counts for 4%Architecture 86 · counts for 2%Security and Compliance 100 · counts for 1%

If Production Readiness rose from 40 to 70, the lowest score rated Strong, the score would rise from 59 to about 72.

Code composition: what the lines of code are
Product code 98%Tests 2%
New since the last survey: 7 findings

These 7 critical or serious findings weren't in the previous survey, on 15 October 2026.

  • Cyclomatic Complexity · ShareToolbarButton.performShareFile (cyclomatic 17) ExcalidrawZ/Share/ShareToolbarButton.swift
  • Cognitive Complexity · ShareToolbarButton.performShareFile (cognitive 29) ExcalidrawZ/Share/ShareToolbarButton.swift
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift
  • Code Duplication · Duplicated block (20 lines × 2) ExcalidrawZ/Share/ExportImageView.swift
  • Churn × Complexity Hotspots · Hotspot: ExcalidrawZ/Share/ShareToolbarButton.swift ExcalidrawZ/Share/ShareToolbarButton.swift
  • Change Coupling · Change coupling: GroupListView.swift ↔ LocalFilesListView.swift ExcalidrawZ/Sidebar/GroupListView.swift

Watchdog compares every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 220 findings

These 220 critical or serious findings were in the previous survey, on 15 October 2026, and are gone from this one. The first 100 are listed here.

  • Cyclomatic Complexity · ExportImageView.actionItems (cyclomatic 18) ExcalidrawZ/Share/ExportImageView.swift
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift
  • Code Duplication · Duplicated block (7–8 lines × 2) ExcalidrawZ/Share/ExportImageView.swift
  • Churn × Complexity Hotspots · Hotspot: ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift
  • Churn × Complexity Hotspots · Hotspot: ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift
  • Exception handling · Swallowed exception (empty catch) ExcalidrawZ/ContentView+/Detail/Home/HomeView.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Binding.id ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Binding.fileID ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Peer.id ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalRelay.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ViewerLocalSocketHandler.sessionID ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalRelay.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CheckpointPreviewSource.cacheID ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFrameLikeElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFrameLikeElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFreeDrawElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFreeDrawElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawDrawElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawDrawElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawGenericElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawGenericElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawIframeLikeElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawIframeLikeElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawImageElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawImageElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawImageElement.fileId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FixedPointBinding.elementID ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LagacyPointBinding.elementID ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawLinearElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawLinearElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawArrowElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawArrowElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPdfElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPdfElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPdfElement.fileId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawTextElement.id ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawTextElement.frameId ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFile.id ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawFile.roomID ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ResourceFile.id ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MetadataMutationKey.locationID ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageFolderPickerContext.id ExcalidrawZ/Persistence/CloudStorage/CloudStorageFolderPicker.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageMetadataOperation.id ExcalidrawZ/Persistence/CloudStorage/CloudStorageMetadataOperation.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageLocation.id ExcalidrawZ/Persistence/CloudStorage/CloudStorageTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageDocumentReference.locationID ExcalidrawZ/Persistence/CloudStorage/CloudStorageTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageDocumentReference.id ExcalidrawZ/Persistence/CloudStorage/CloudStorageTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageDocumentReference.activeFileID ExcalidrawZ/Persistence/CloudStorage/CloudStorageTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CloudStorageFolderReference.id ExcalidrawZ/Persistence/CloudStorage/CloudStorageTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: EncryptedBackupEnvelope.keyID ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: EncryptedContentEnvelope.contentID ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: UnlockedContentKey.contentID ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileStorageICloudStatusMonitor.monitoredFileID ExcalidrawZ/Persistence/FileStorage/FileStorageICloudStatusMonitor.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileChangeEvent.fileID ExcalidrawZ/Persistence/FileStorage/FileStorageManager.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MigrationFailedItem.id ExcalidrawZ/Persistence/Migrations/MigrationState.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MigrationItem.id ExcalidrawZ/Persistence/Migrations/MigrationState.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: PersistedFile.fileID ExcalidrawZ/Persistence/Repository/AIChatAttachmentRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIConversationFileScope.id ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIConversationSnapshot.conversationID ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIConversationSnapshot.fileScopeID ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIConversationMessageSnapshot.messageID ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIConversationMessageSnapshot.toolCallId ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIMessageCheckpointLinkSnapshot.conversationID ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIMessageCheckpointLinkSnapshot.messageID ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIMessageCheckpointLinkSnapshot.checkpointID ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIMessageCheckpointLinkSnapshot.fileScopeID ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: RawCheckpointContentSnapshot.checkpointID ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LockedFileSummary.id ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LockedFileSummary.fileID ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: RawFileContentSnapshot.fileID ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: DeletedFileStorageInfo.fileID ExcalidrawZ/Persistence/Repository/FileRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: DeletedCheckpointStorageInfo.checkpointID ExcalidrawZ/Persistence/Repository/FileRepository.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MediaCleanupCandidate.mediaID ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: StoredContentSnapshot.contentID ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MediaSnapshot.mediaID ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: MCPServiceModeFeature.id ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LockedFileAccessRequest.id ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LockedFileAccessRequest.fileID ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: CheckpointRecoveryData.id ExcalidrawZ/Sidebar/components/MissingFileMenu.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: TreeStructureChild.id ExcalidrawZ/Sidebar/components/TreeStructureView.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: AIChatIslandProposal.messageID ExcalidrawZ/SidebarTrailing/AIChat/AIChatIslandProposal.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawAITransactionMetadata.conversationID ExcalidrawZ/SidebarTrailing/AIChat/ExcalidrawAITransactionMetadata.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawAITransactionMetadata.userMessageID ExcalidrawZ/SidebarTrailing/AIChat/ExcalidrawAITransactionMetadata.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawAITransactionMetadata.agentID ExcalidrawZ/SidebarTrailing/AIChat/ExcalidrawAITransactionMetadata.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawAITransactionMetadata.modelProfileID ExcalidrawZ/SidebarTrailing/AIChat/ExcalidrawAITransactionMetadata.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawAITransactionMetadata.fileID ExcalidrawZ/SidebarTrailing/AIChat/ExcalidrawAITransactionMetadata.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileIDProbe.fileID ExcalidrawZ/SidebarTrailing/AIChat/LockedContentAIGuard.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawLibrary.id ExcalidrawZ/SidebarTrailing/Library/LibraryModel.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Item.id ExcalidrawZ/SidebarTrailing/Library/LibraryModel.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Page.frameID ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationConfiguration.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Page.id ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationConfiguration.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LoadIdentity.fileID ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationModel.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPresentationSlide.id ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPresentationSession.id ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ExcalidrawPresentationSession.initialSlideID ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationTypes.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: LoadTaskIdentity.fileID ExcalidrawZ/SidebarTrailing/Presentation/PresentationInspectorContent.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileStatusDeliveryState.fileID ExcalidrawZ/Utils/FileStatusObserver/FileStatusObserverModifier.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileVersion.id ExcalidrawZ/Utils/ICloudFileKit/ICloudConflictResolver.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: FileHomeNativeTransitionProbe.fileID ExcalidrawZ/ContentView+/Detail/Components/FileHomeNativeTransitionBridge.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: ProbeView.fileID ExcalidrawZ/ContentView+/Detail/Components/FileHomeNativeTransitionBridge.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: Request.id ExcalidrawZ/ContentView+/Detail/Components/FileHomeSheetPresentation.swift
  • Strongly-typed ids · Raw-primitive id despite a typed-id idiom: RecentlyFilePresentationKey.id ExcalidrawZ/ContentView+/Detail/Home/HomeView.swift
Rebuild cost: about €160,000 · Estimate
Cost to rebuild€54,000 to €270,000, for 908 to 2,881 hours of work, about 1.1 person-years for 1 to 3 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.8 at a score of 59. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeLarge: 152,488 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Resolve the 6 Floating branch dependency finding(s) in Dependency Hygiene.
Raises the score by about 6 points · Low effort · Dependency Hygiene
2
Resolve the 1 Assertions commented out finding(s) in Test Quality — start with ExcalidrawZUITests.swift.
Raises the score by about 5 points · Low effort · Test Quality
3
Resolve the 1 Test project verifies nothing finding(s) in Test Quality — start with ExcalidrawZUITests.swift.
Raises the score by about 5 points · Low effort · Test Quality

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €160,000 to build again, about 1.1 person-years of work. Its weakest lens is Production Readiness, at 40 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
One cause behind 42 Domain Modelling findings · Common cause
42 findings in the Domain Modelling lens come from the same cause. The code models the business as objects, such as an order or a customer, and each object should guard its own rules: an order, for example, should refuse to be shipped before it has been paid. Here the objects don't do that. Some objects only hold data, while the rules that should keep that data valid sit elsewhere in the code. Identifiers, such as order numbers and customer numbers, are passed around as plain numbers or text, so nothing stops the code from using one kind where another belongs. Because all of these findings have the same cause, fixing it once, in the business objects themselves, deals with them together.
Based on: Rich vs anemic domain model (2 findings) · Strongly-typed ids (40 findings)
What to do: Give each business object the methods that enforce its rules, such as a method for shipping an order that first checks it has been paid, and let only those methods change its data. Give each kind of identifier a type of its own, so an order number can't be used where a customer number belongs.
If you do one thing first · First action
Resolve the 6 Floating branch dependency finding(s) in Dependency Hygiene. Of all the actions in this report, it raises the score most for the work it takes: about 6 points for low effort, because it clears the 6 Dependency Hygiene findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort

Architecture — module dependency graph

Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.

arch ExcaliDrawZ ExcaliDrawZ QuickLookPreviewExtension QuickLookPreviewExtension

At a glance — Code Health · 80% · Strong ·

At a glance — Architecture · 86% · Adequate · gated by D26 ·

At a glance — Maturity · 69% · Adequate · gated by M2 ·

At a glance — Readiness · 40% · Weak · gated by P1, P3 ·

At a glance — Security · 100% · Exemplary ·

At a glance — Domain Modelling · 84% · Strong ·

At a glance — Performance · 77% · Strong ·

Roadmap

Establish a CI workflow to build and test on every push to ensure immediate feedback on changes. Address dependency hygiene by resolving floating branch issues and improve test quality by fixing commented-out assertions and verifying the test project actually runs. Finally, document architectural decisions by creating the first Architecture Decision Record.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Resolve the 6 Floating branch dependency finding(s) in Dependency Hygiene.+6.5 ptsLowDependency Hygiene
Resolve the 1 Assertions commented out finding(s) in Test Quality — start with ExcalidrawZUITests.swift.+4.6 ptsLowTest Quality
Resolve the 1 Test project verifies nothing finding(s) in Test Quality — start with ExcalidrawZUITests.swift.+4.6 ptsLowTest Quality
Add a CI workflow that builds and runs the test suite on every push/PR.+8.4 ptsMediumCI/CD gates
Resolve the 1 No ADRs found finding(s) in ADR Quality.+3.3 ptsLowADR Quality
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.+3.0 ptsMediumArchitecture documentation
Resolve the 5 No assertions finding(s) in Test Quality — start with PersistenceTests.swift (2), ExcalidrawFileTests.swift, ExcalidrawZUITests.swift.+1.2 ptsLowTest Quality
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.+2.0 ptsMediumDocumentation (README)

File quality

Per-file score 0–10 — a quality signature. Of 265 files carrying findings, judged against the Production bar: 0% slop · 57% mixed · 43% near-clean.

FileScoreBandWorst signal
ExcalidrawZ/Store/FileState.swift5.5MixedCyclomatic Complexity: FileState.performActiveFileChange (cyclomatic 45)
ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift5.5MixedCyclomatic Complexity: ExcalidrawEditor.persistCanvasUpdate (cyclomatic 19)
ExcalidrawZUITests/ExcalidrawZUITests.swift5.5MixedTest Quality: Assertions commented out: testExample
ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift5.5MixedCyclomatic Complexity: ScreenAnnotationSession.prepareCanvas (cyclomatic 18)
ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift5.5MixedCyclomatic Complexity: FileHomeItemContentView.content (cyclomatic 35)
ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift5.6MixedGod Classes: ClassTooLong: ExcalidrawMCPAppBridge
ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift5.9MixedCyclomatic Complexity: AIChatView.messageList (cyclomatic 18)
ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift5.9MixedCognitive Complexity: ExcalidrawCore.waitUntilReadyForFileLoad (cognitive 18)
ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift5.9MixedCode Duplication: Duplicated block (41 lines × 2)
ExcalidrawZ/components/NewFileButton.swift6.0MixedExplicit Debt: TodoComment
ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift6.0MixedExplicit Debt: TodoComment
ExcalidrawZ/AppDelegate.swift6.3MixedCyclomatic Complexity: AppDelegate.scheduleTerminationSheetIfNeeded (cyclomatic 17)
ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift6.3MixedCognitive Complexity: CompactAIChatReplyTicker.handleReplyTickerVisibility (cognitive 17)
ExcalidrawZ/ContentView.swift6.3MixedGod Classes: MethodTooLong: ContentView.body
ExcalidrawZ/Persistence/PersistenceController.swift6.3MixedCode Duplication: Duplicated block (5 lines × 2)
ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift7.0MixedCyclomatic Complexity: FileCoverCacheCoordinator.generate (cyclomatic 30)
ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift7.0MixedCyclomatic Complexity: CloudStorageDocumentStore.replayPendingMetadataOperations (cyclomatic 26)
ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift7.0MixedCyclomatic Complexity: AdjustElementsTool.execute (cyclomatic 20)
ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift7.0MixedCognitive Complexity: Migration_MoveContentToICloudDrive.migrateFiles (cognitive 27)
ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift7.0MixedCognitive Complexity: CompactExcalidrawBottomToolbarContent.body (cognitive 22)

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 44

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 807

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 40

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 22

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 59 of 59 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.8 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.

Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.

What we checked — 59 dimensions across the health lenses
D1D2D3D4D5D6D9D10D12D13D14D15D17D20D26D28D29D30D34D35D43AX10AX3AX4AX8AX9DM2DM4DM5DM6M1M2M3M4P1P2P3P6PF2PF3X1X12X13X14X15X16X17X18X19X21X22X23X24X25X26X28X29X3X30

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 874 of 891 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Watchdog duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivySecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3✓ deterministic
LLM (sampled · advisory)Documentation quality, ADR conformance, naming — sampled over a bounded sample; advisory, never a deterministic measurement—◐ LLM · sampled · advisory

Every finding is locatable in findings.md. Run 01a18781-b9a7-7b4c-afd2-f676299846b9.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D16 Bus Factor — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. Single-maintainer repository — bus factor is not applicable (9 contributor(s) across 871 commit(s) sampled, automation and bot accounts excluded). One of them holds 99% of the history; the other 8 hold 0.1% each on average, below the 5% at which there is somebody to hand the work to. That is a single maintainer with drive-by contributors, not a team whose knowledge has concentrated — so the bus factor is not applicable and there is nothing here for the owner to act on.
  • D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
  • D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is an ADMISSION gap, not an environment fault: no published-package marker D22 reads admitted any project here. D22 DOES collect the public API of every language in this tree, and admits a project only when its manifest makes that ecosystem's publication act in a form the marker recognises — so what is missing is not a collector but an admission rule for the publication act this repository makes, if it makes one. The remedy is a better discriminator for that marker — not a collector, and no change to the scan image can close it. The marker's rules are measured to refuse applications, so one refused repository is the rule working as calibrated; several are the evidence that it is too strict. For npm the surface is what a published package.json's entry points (exports, main, module, types) export, followed through the source; an entry that names build output the tree does not commit (dist/, build/) is not followed back to source, because only a tsconfig outDir/rootDir pair states that mapping and a bundler's input lives in executable configuration this engine does not evaluate.
  • D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
  • D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
  • D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileICloudStatusIndicator.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileICloudSyncStatusIndicator.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift`, `ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift`, … (+135 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
  • D44 Platform End-of-Life — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This dimension reads a project's own statement about the platform it runs on: a TargetFramework in a .NET project file, a .nvmrc or .python-version, a capped requires-python, a Rust toolchain file or Cargo.toml rust-version, a .go-version, .java-version, .ruby-version, .tool-versions or .sdkmanrc, a go.mod go directive, a Maven or Gradle Java level or toolchain, a Gemfile's ruby directive, a mix.exs elixir requirement, a rebar.config minimum_otp_vsn, a pubspec.yaml SDK constraint, a build.sbt scalaVersion, or a framework major pinned by a dependency constraint. This repository carries none of them, so nothing about its platform was established. That is a gap in this analyzer's coverage, NOT a finding that the platform is supported — a language whose runtime is declared elsewhere (Package.swift, a Dockerfile) is simply not read here yet.
  • AX1 Captive dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in ExcalidrawZ/Resources/MathRendering/function-plot-1.25.4.js, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AX6 Interface segregation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AXB1 Runtime evidence locked — no reproducible boot — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Subject: a native UI project (ExcalidrawZ.xcodeproj/project.pbxproj). The Runtime Evidence tier boots an app only via docker-compose, an Aspire AppHost, a Dockerfile, an npm dev script, a web service's own toolchain entry point (cargo, go, dotnet, Python, Spring Boot), or an Android app's own Gradle wrapper (run on an emulator); an Apple or Flutter app needs a host it lacks. None applied, so no live runtime a11y/egress/header evidence was collected. You can widen what we reach: add a docker-compose.yml (or an Aspire AppHost) that brings the app up with its dependencies. Watchdog then boots it in an isolated sandbox and gathers real runtime evidence — you change nothing in your pipeline (no CI step, no SDK).
  • C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • C2 Access Controls — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
  • C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
  • C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'CoreData' is imported (QuickLookPreviewExtension/PreviewViewController.swift:13), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
  • C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'CoreData' is imported (QuickLookPreviewExtension/PreviewViewController.swift:13), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
  • DM2 Strongly-typed ids — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 213 further occurrence(s) are not listed individually; the score already reflects all 253.
  • GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Swift is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Swift is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
  • S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
  • X2 Cancellation propagation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Go, PHP, Dart, Kotlin, Ruby, Scala, Java, Python and Rust source only, and no C# was loaded, and no named async function in this repository's JavaScript/TypeScript, nor any Go, PHP or Dart function or Kotlin suspend function, makes a request that can be cancelled (fetch, axios, ky, ofetch; net/http, net.Dial; amphp; Dio; Ktor, OkHttp), so there is nothing to judge, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X27 Collection changed while being enumerated — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and Java, Rust, Erlang, F#, Python, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded, no Java, Rust, Erlang, F#, Python, Dart, Ruby, Scala or Kotlin was found, and this repository's Swift (Foundation mutable collections) is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X3 Exception handling — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 1 further occurrence(s) are not listed individually; the score already reflects all 41.
  • X4 Structured logging — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Kotlin, Python, PHP, Dart, Ruby, Scala and Rust source only, and no C# was loaded, and this repository's JavaScript/TypeScript, Python and PHP make no call through a named logger, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X5 Nullable reference types — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax and MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, and Kotlin source only, and no C# was loaded, no TypeScript was found, and this repository's Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
  • D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
  • D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
  • D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
  • DM4 Rich vs anemic domain model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
  • DM6 Domain ↔ infrastructure boundary: Infrastructure reached through a hand-rolled wrapper, a domain-named facade, reflection, or a string-keyed service locator resolves to a non-infra type and isn't seen; the body scan is symbol resolution over syntax, not full dataflow. A clean result means "no resolved infra reference in a domain body", not a proof of purity.
  • M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity6.8 / 10Adequate✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 6.8 / 10 · rule-coverage 100% · ceiling Prevented

83 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was ExcalidrawCore.userContentController at 49. A further 14 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being WindowEvent.notificationName at 30 — they are counted neither in the figure above nor in this dimension's score. 5 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: ExcalidrawZ/Extensions/Window+Extension.swift (WindowEvent.notificationName at 30), ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadPicker.swift (ArrowheadPicker.swift.arrowheadIcon at 23), ExcalidrawZ/SidebarTrailing/AIChat/components/ToolCards/ToolCallCard.swift (ToolCallVisualStyle.style at 19), ExcalidrawZ/Store/ToolState.swift (ExcalidrawTool.icon at 18), ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift (BridgeError.errorDescription at 16). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

ExcalidrawCore.userContentController (cyclomatic 49)ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:24
AdjustElementsMiddleware.patchElement (cyclomatic 48)ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:25
FileState.performActiveFileChange (cyclomatic 45)ExcalidrawZ/Store/FileState.swift:669
ViewerLocalConnection.update (cyclomatic 40)ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift:77
DrawingSettingsPanel.body (cyclomatic 37)ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsPanel.swift:18

+ 77 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 11 bodies over 30 down to 30 or less in Cyclomatic Complexity — start with ExcalidrawCore.userContentController (cyclomatic 49), AdjustElementsMiddleware.patchElement (cyclomatic 48), FileState.performActiveFileChange (cyclomatic 45). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 11 together lifts Cyclomatic Complexity from 6.8 to about 7.3/10, projected with the scoring formula itself and assuming each lands exactly at 30; a cleaner split scores higher.
  2. Stand up a CI pipeline, then gate Cyclomatic Complexity in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity6.1 / 10Adequate✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 6.1 / 10 · rule-coverage 100% · ceiling Prevented

179 method(s) exceeded the cognitive complexity threshold of 15; the worst was AdjustElementsMiddleware.patchElement at 89.

AdjustElementsMiddleware.patchElement (cognitive 89)ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:25
FileRowDragDropModifier.sortFiles (cognitive 87)ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:268
ExcalidrawHomeView.handleActiveGroupChanged (cognitive 69)ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:277
FileState.performActiveFileChange (cognitive 68)ExcalidrawZ/Store/FileState.swift:669
ExcalidrawRenderer.canvasView (cognitive 66)ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:63

+ 173 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 5 bodies over 60 down to 60 or less in Cognitive Complexity — start with AdjustElementsMiddleware.patchElement (cognitive 89), FileRowDragDropModifier.sortFiles (cognitive 87), ExcalidrawHomeView.handleActiveGroupChanged (cognitive 69). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 5 together lifts Cognitive Complexity from 6.1 to about 6.5/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Stand up a CI pipeline, then gate Cognitive Complexity in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.0 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 100% · ceiling Prevented

96 god class(es) detected.

MethodTooLong: WhatsNewView.allFeaturesList · ×34ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:43
FileTooLong: CloudStorage/CloudStorageDocumentStore.swift · ×29ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift
ClassTooLong: CloudStorageDocumentStore · ×18ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:14
TooManyMethods: ExcalidrawCore · ×15ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift:13

What to do

  1. Resolve the 34 MethodTooLong finding(s) in God Classes — start with ExcalidrawHomeView.swift (2), WhatsNewSheetView+allFeatures.swift, ReadFileTool.swift. — One of this dimension's main actionable groups (34 warning-level).
  2. Resolve the 29 FileTooLong finding(s) in God Classes — start with CloudStorageDocumentStore.swift, FileState.swift, ExcalidrawMCPAppBridge.swift. — One of this dimension's main actionable groups (29 warning-level).
  3. Resolve the 18 ClassTooLong finding(s) in God Classes — start with CloudStorageDocumentStore.swift, FileState.swift, ExcalidrawMCPAppBridge.swift. — One of this dimension's main actionable groups (18 warning-level).
  4. Stand up a CI pipeline, then gate God Classes in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication8.9 / 10Strong✓ Tool-verified

What it measures: Copy-pasted code that should be shared instead.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.9 / 10 · rule-coverage 100% · ceiling Verified

331 duplicated block group(s) detected. A further 17 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted.

Duplicated block (7 lines × 2) · ×22ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:586
Duplicated block (8 lines × 2) · ×21ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:10
Duplicated block (6 lines × 2) · ×19ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWelcomeView.swift:72
Duplicated block (9 lines × 2) · ×18ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:211
Duplicated block (12 lines × 2) · ×17ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:213

+ 108 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 22 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with FlexibleSplitLayout.swift (2), EncryptedBackupService.swift (2), ExcalidrawEditorToolbarModifier.swift. — One of this dimension's main actionable groups (22 warning-level).
  2. Resolve the 21 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with CompactExcalidrawBottomToolbarContent.swift (2), ExcalidrawImageRenderer_CoreData.swift, MathInputSheetView+Workspace.swift. — One of this dimension's main actionable groups (21 warning-level).
  3. Resolve the 19 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with LatexMathWebRenderer.swift (3), ScreenAnnotationWelcomeView.swift, DropboxOAuthAuthenticator.swift. — One of this dimension's main actionable groups (19 warning-level).
  4. Stand up a CI pipeline, then gate Code Duplication in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

2 production modules (Xcode), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; a workspace's implicit (product-name) dependency is not visible there; 0 module(s) off the main sequence, with abstractness counted on 1 of the 2 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

✓ On the Gold path — maintain.

Detailed fixes: d5_recommendation.md.

D6 · Cohesion (LCOM4)8.7 / 10Strong✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 8.7 / 10 · rule-coverage 100% · ceiling Verified

17 of 157 classes have LCOM4 above 3.

Low cohesion: AIConversationRepository (LCOM4 17) · ×17ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:69

What to do

  1. Resolve the 17 Low cohesion finding(s) in Cohesion (LCOM4) — start with AIConversationRepository.swift, ExcalidrawCore.swift, PersistenceController.swift. — One of this dimension's main actionable groups (17 warning-level).
  2. Stand up a CI pipeline, then gate Cohesion (LCOM4) in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D9 · Test Distribution9.7 / 10Exemplary✓ Tool-verified

What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.

Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.7 / 10 · rule-coverage 100% · ceiling Documented

138 test methods: 135 unit, 0 integration, 0 BDD, 3 e2e.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D10 · Test Quality9.2 / 10Adequategated by 2 critical findings✓ Tool-verified

What it measures: Whether the tests truly assert behaviour rather than just running the code.

Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.2 / 10 · rule-coverage 100% · ceiling Prevented

0 skipped, 6 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 138 tests.

Assertions commented out: testExampleExcalidrawZUITests/ExcalidrawZUITests.swift:25
Test project verifies nothing: ExcalidrawZUITestsExcalidrawZUITests/ExcalidrawZUITests.swift:25
No assertions: testPerformanceOfEncoding · ×5ExcalidrawZTests/ExcalidrawFileTests.swift:308

What to do

  1. Resolve the 1 Assertions commented out finding(s) in Test Quality — start with ExcalidrawZUITests.swift. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 1 Test project verifies nothing finding(s) in Test Quality — start with ExcalidrawZUITests.swift. — One of this dimension's main actionable groups (1 issue-level).
  3. Resolve the 5 No assertions finding(s) in Test Quality — start with PersistenceTests.swift (2), ExcalidrawFileTests.swift, ExcalidrawZUITests.swift. — One of this dimension's main actionable groups (5 warning-level).
  4. Stand up a CI pipeline, then gate Test Quality in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.

D12 · Dependency Hygiene8.2 6.4 / 10Adequate✓ Tool-verified

What it measures: Whether dependencies are current, secure, and not bloated.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 6.4 / 10 · rule-coverage 79% · ceiling Verified

6 outdated direct SwiftPM dependencies, 6 pinning defect(s). 22 of 28 direct dependencies had their releases listed (0 naming no readable repository, 6 pinned to a branch or a revision rather than a version). SwiftPM has no package registry: a dependency is a repository URL and its releases are that repository's semver tags, so currency is answered by listing tags rather than by querying an index. Only a newer tag on the SAME MAJOR is reported — a `from:` requirement admits everything below the next major and nothing above it, so a major crossing needs a Package.swift edit rather than an update, and naming the update as its remedy would be wrong. Whether any dependency is DEPRECATED or ABANDONED is not graded and cannot be: a repository publishes no such marker, and there is no registry that could carry one. Known CVEs in this dependency graph are D30's question.

Floating branch dependency: alerttoast · ×6
Outdated: kingfisher · ×6

What to do

  1. Resolve the 6 Floating branch dependency finding(s) in Dependency Hygiene. — One of this dimension's main actionable groups (6 warning-level).
  2. Stand up a CI pipeline, then gate Dependency Hygiene in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · Secret Scanning10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

Secret scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 28 SwiftPM package(s) use a banned license. SwiftPM has no package registry, so each package's licence is the one its repository declares: 25 of them read from the licence file the repository carries at the revision Package.resolved pins, and 3 — unpinned, or whose licence file could not be read or named — from api.deps.dev, which reports the licence the repository declares today. Graded: every package a committed Package.resolved pins, direct and transitive, and every declared dependency none pins. 4 of them declare no licence that matches a known SPDX licence; that is missing data, not a violation, and none of them is charged.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots9.6 / 10Stronggated by 15 serious findings✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 9.6 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: ExcalidrawZ/Store/FileState.swift (10×45=450); ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift (8×35=280); ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift (12×19=228) Repeated repair below the complexity floor: ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift (4 of 5 changes were fixes); ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift (3 of 5 changes were fixes)

Hotspot: ExcalidrawZ/Store/FileState.swift · ×13ExcalidrawZ/Store/FileState.swift:669
Repeated repair: ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift · ×2ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:107

What to do

  1. Resolve the 13 Hotspot finding(s) in Churn × Complexity Hotspots — start with FileState.swift, FileHomeItemView.swift, ExcalidrawEditor.swift. — One of this dimension's main actionable groups (13 warning-level).
  2. Resolve the 2 Repeated repair finding(s) in Churn × Complexity Hotspots — start with ExcalidrawWebView.swift, LocalFilesProvider.swift. — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 8 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

8 deducted task-comment markers across 152488 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×8ExcalidrawZ/components/NewFileButton.swift:70

What to do

  1. Resolve the 8 TodoComment finding(s) in Explicit Debt — start with AIChatErrorPresenter.swift (2), ExcalidrawWebView.swift (2), NewFileButton.swift. — One of this dimension's main actionable groups (8 warning-level).
  2. Stand up a CI pipeline, then gate Explicit Debt in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D26 · Project Cohesion0.0 / 10Critical✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic, LLM-independent.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 build units (Xcode) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D28 · Secrets (history)10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

gitleaks scanned the full history AND the current working tree and found no secrets.

✓ On the Gold path — maintain.

Detailed fixes: d28_recommendation.md.

D29 · Static Analysis (SAST)10.0 / 10Exemplary○ Nothing flagged

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

semgrep found no security issues. semgrep hit a parse error in 14 file(s) — `ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift` (line 283, lines 284–286, line 288), `ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift` (lines 401–414, line 416, lines 416–426, …), `ExcalidrawZ/ExcalidrawZApp.swift` (line 263), `ExcalidrawZ/Persistence/CloudStorage/CloudStorageConnectionStore.swift`, `ExcalidrawZ/Persistence/PersistenceController.swift` (line 63, line 65, line 86, …), … (+9 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them.

✓ On the Gold path — maintain.

Detailed fixes: d29_recommendation.md.

D30 · Dependency Vulnerabilities10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No known-vulnerable dependencies in any ecosystem this repository declares.

✓ On the Gold path — maintain.

Detailed fixes: d30_recommendation.md.

D34 · Knowledge Freshness10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

Every significant source file has living knowledge — recently and meaningfully worked. Counted over 516 of the 716 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

✓ On the Gold path — maintain.

Detailed fixes: d34_recommendation.md.

D35 · Change Coupling9.8 / 10Stronggated by 11 serious findings✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: CompactAIChatInputOverlay.swift↔CompactExcalidrawBottomToolbarContent.swift 70%; ContentView.swift↔ExportFileView.swift 64%; ExportFileView.swift↔ExportImageView.swift 64%

Change coupling: CompactAIChatInputOverlay.swift ↔ CompactExcalidrawBottomToolbarContent.swift · ×11ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift:1

What to do

  1. Resolve the 11 Change coupling finding(s) in Change Coupling — start with CompactAIChatInputOverlay.swift (2), ContentView.swift (2), ExportFileView.swift. — One of this dimension's main actionable groups (11 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition8.3 / 10Strong✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

What to do

  • The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.

Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

DM2 · Strongly-typed ids7.6 / 10Strong✓ Tool-verified

Other · Domain Modelling — Whether domain identifiers are strongly typed (a typed-id struct) rather than raw primitives — consistency once an idiom exists.

Method: Roslyn (DDD-gated): strongly-typed id adoption on domain entities/events; raw Guid/int/string ids counted versus wrapped types. An id wrapper is recognised by VALUE SEMANTICS, not by being a struct — a record struct, a record class (`record ApartmentId(Guid Value)`) or a class declared by a typed-id base (`class MemberId : TypedIdValueBase`) all count, while a plain mutable class (reference equality) and a verb-phrase query record (`GetCustomerById`) do not. Deterministic, adoption percentage.

Coverage: Population: id-like members by *Id/*Key NAME suffix; strongly-typed-ID shape then checked semantically — non-suffixed identifiers are not seen.

  • `ExcalidrawBoundElement.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Models/ExcalidrawElementBase.swift:43
  • `FileLocalizable.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Persistence/File+Persistence.swift:36
  • `FileLocalizable.groupID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Persistence/File+Persistence.swift:37
  • `FileRecord.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Persistence/SpotlightDelegate.swift:266
  • `AccountEntry.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Settings/CloudStorageSettingsView.swift:14
  • `FolderChildren.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Settings/GeneralSettingsView.swift:25
  • `RecoveryKeyResetRequest.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Settings/SecuritySettingsView.swift:826
  • `EditSession.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:146
  • `EditSession.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:147
  • `TransientError.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:152
  • `TransientError.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:153
  • `TransientError.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:154
  • `TransientError.retryModelProfileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/AIChatState.swift:158
  • `CapturedCanvasSaveTarget.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/FileState.swift:408
  • `AIChatSessionState.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/FileState.swift:1081
  • `AIChatSessionState.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/FileState.swift:1083
  • `AIChatSessionState.preCheckpointID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/FileState.swift:1094
  • `LockedContentAutomaticUnlockRequest.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/LockedContentStateStore.swift:13
  • `ManagedFileReference.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Store/LockedContentStateStore.swift:48
  • `SubscriptionItem.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Subscription/Store_Shared.swift:153
  • `SubscriptionItem.yearlyID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Subscription/Store_Shared.swift:154
  • `FailedFileInfo.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Utils/ArchiveFilesModifier.swift:18
  • `ArchiveFileSnapshot.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Utils/ArchiveFilesModifier.swift:377
  • `IdentifiableError.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Utils/Error.swift:15
  • `Secrets.oneDriveClientID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Utils/Secrets.swift:14
  • `Secrets.googleDriveClientID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/Utils/Secrets.swift:15
  • `ActiveStorageFileReference.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+FileStatusObserver.swift:799
  • `LoadingOverlayCover.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:17
  • `SyncIndicatorEvent.presentationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/IndicatorOverlay.swift:437
  • `ExcalidrawDocumentLoadCompletion.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockOverlayModifier.swift:13
  • `LockedFileUnlockRequest.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:16
  • `LockedFileUnlockTaskID.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:444
  • `DocumentLoadStateMachine.confirmedFileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:18
  • `Request.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:13
  • `Request.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:15
  • `ExcalidrawDocumentSyncController.currentLoadedFileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:146
  • `StateChangeSuppression.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:123
  • `StoredViewportState.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawViewportStateStore.swift:30
  • `ViewerLocalConnection.requestedFileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift:40
  • `ViewerLocalConnection.awaitingPresentationSessionID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value. — ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift:42

What to do

  • Adopt the repo's typed-id idiom consistently — wrap every entity identity in its own typed id.
DM4 · Rich vs anemic domain model7.3 / 10Strong✓ Tool-verified

Other · Domain Modelling — Whether domain entities own their behaviour — a data-only reference entity whose logic lives in a foreign service is anemic. Rich models enforce their own invariants.

Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.

Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.

  • `String` is a data-only reference entity whose behaviour is DELEGATED to a foreign utility (static methods that take it as their first parameter and hold its logic) — the anemic domain model. Move the behaviour onto the entity so it enforces its own invariants rather than being driven from outside. — ExcalidrawZ/Extensions/String+Extension.swift:10
  • `Group` is a data-only reference entity whose behaviour is DELEGATED to a foreign utility (static methods that take it as their first parameter and hold its logic) — the anemic domain model. Move the behaviour onto the entity so it enforces its own invariants rather than being driven from outside. — ExcalidrawZ/Persistence/Group+Persistence.swift:12

What to do

  • Move delegated behaviour onto the domain entity (or make it a value object); keep invariants inside the type.
DM5 · Encapsulated state10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether a reference entity protects its own invariants — a class whose identity is a computed content hash but whose hashed fields are publicly mutable bypasses that invariant. Encapsulated state keeps identity-bearing fields immutable.

Method: Roslyn (DDD-gated): entities scanned for publicly writable state — public setters, and (C#/VB) own mutable collections handed out through an auto-property, a public field or a bare-field expression getter, where a computed/copying getter is never charged. One finding per entity; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.

Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.

DM6 · Domain ↔ infrastructure boundary10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether the domain layer stays free of infrastructure dependencies — a domain entity fused to a persistence ORM on its own declaration (active-record), or reaching a web-framework transport type in its own method, couples the domain to infrastructure. The clean-architecture dependency rule.

Method: Roslyn (DDD-gated): domain-layer types scanned for infrastructure usage in member SIGNATURES and inside method/accessor BODIES — resolved calls and object-creations into EF/Marten/HTTP/Mongo/Redis/message-bus types (not just a namespace allowlist). Deterministic, symbol-resolved, exhaustive over domain-layer bodies, DDD-native.

Coverage: Domain layer identified by NAMESPACE heuristic; infrastructure then resolved by symbol in member SIGNATURES and method/accessor BODIES — rename the layer and the check evaporates.

M1 · Documentation (README)6.7 / 10Adequate✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
  • Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
M2 · Architecture documentation3.0 / 10Weak✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

M4 · Documentation accuracy10.0 / 10Exemplary○ Nothing flagged

Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).

Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.

P1 · CI/CD gates0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

  • No CI workflow found (.github/workflows, azure-pipelines.yml, .gitlab-ci.yml, …) — changes aren't gated by an automated build/test.

What to do

  • Add a CI workflow that builds and runs the test suite on every push/PR.
P2 · Observability7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

P3 · Security & performance tooling0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) — this repository has no CI pipeline yet, so run it locally to clear the existing findings, then make it a step of the first workflow you add so a regression fails the build. What was searched, so you can tell an absence from a miss: the 0 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.

What to do

  • Run what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — locally for now, since there is no CI pipeline here yet, and as a step of the first workflow you add so a security regression fails the build instead of landing.
  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

PF2 · Allocation hygiene6.0 / 10Adequate✓ Tool-verified

Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.

Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.

What to do

  • Raise allocation-aware density on the hot paths — currently 13 use(s) across 170,465 production line(s) (~0.1/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
  • Swift: on hot paths, reserveCapacity before appending, use ContiguousArray for class-element arrays, work in place with withUnsafeBufferPointer/withUnsafeTemporaryAllocation, and make large values ~Copyable with borrowing/consuming parameters.
PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.

Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.

X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.

Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

X16 · Unfloored truncation loop10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.

Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.

X17 · Uncapped recursion over a caller-supplied document10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.

Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.

X18 · Disposal-pattern correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.

Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.

X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.

Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.

X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.

Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.

X23 · Unguarded diagnostic materialisation10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.

Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.

X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.

Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.

Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.

Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.

Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.

X3 · Exception handling6.5 / 10Adequate✓ Tool-verified

Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.

Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.

  • `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×35) — ExcalidrawZ/Utils/Utils.swift:411, ExcalidrawZ/Utils/Utils.swift:496, ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:1647, …
  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×5) — ExcalidrawZ/Utils/FileSyncCoordinator/LocalFolder+FileSyncCoordinator.swift:21, ExcalidrawZ/Store/AppPreference.swift:171, ExcalidrawZ/Store/FileState.swift:789, …

What to do

  • Swallowed exception (caught, then discarded)
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health80%StrongSolid.
Architecture86%Adequate — gated by D26Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Maturity69%Adequate — gated by M2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Readiness40%Weak — gated by P1, P3Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security100%ExemplaryStrongest area.
Domain Modelling84%StrongSolid.
Performance77%StrongSolid.
Unscored — 2 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 5 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 5 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C4 Data Retention — Not assessed: this repository stores data through 'CoreData' (QuickLookPreviewExtension/PreviewViewController.swift:13) but declares no persisted model this check reads (SwiftData @Model, Core Data, Realm, GRDB and Fluent types, GRDB and SQLite.swift columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL migrations). Personal data may be written through raw SQL or a hosted backend, so whether a retention limit applies here could not be established, and its absence is not scored.
  • C5 Data-Subject Rights — Not assessed: this repository stores data through 'CoreData' (QuickLookPreviewExtension/PreviewViewController.swift:13) but declares no persisted model this check reads (SwiftData @Model, Core Data NSManagedObject, Realm Object, GRDB record and Fluent Model properties, GRDB and SQLite.swift columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether data-subject rights apply here could not be established, and their absence is not scored.
  • P4 Deployment & Rollback — not evidenced — no deploy/rollback/approval signal in the repo; absence of evidence is not evidence of a manual release
  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 58 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
  • AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
  • AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
  • AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
  • AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
  • AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
  • AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
  • AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No Swift request handler (a Vapor, Hummingbird, Kitura, Swifter or Perfect route handler, as a method or a registered closure) is declared, so no state is shared between request threads. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AXB1 Runtime evidence locked — no reproducible boot — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • D11 Test Reliability — Test source is present (.swift) and this repository's suite is reachable only from an Apple platform: it ships ExcalidrawZ.xcodeproj and no SwiftPM manifest, so it is built by Xcode rather than by `swift test`. The analyzer runs on Linux, where no simulator exists, so the suite was not re-run. Not scored: nothing was exercised.
  • D16 Bus Factor — single-maintainer repository — bus factor is not applicable
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D19 Documentation Quality — No runnable or published unit to look for an example in, and no multi-project root README to look for a map in; the other documentation kinds are withheld (see the gaps), so documentation quality is not applicable here.
  • D21 Naming Consistency — Naming consistency is measured on C# only; JavaScript, Swift not measured.
  • D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D24 Comment Value — D24 reads C# and Visual Basic comments only — this repository's production source is .swift, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.swift), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
  • D32 Data Compliance (PII/GDPR) — 140 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
  • D36 Supply-chain Provenance & Signing — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.
  • D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
  • D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D44 Platform End-of-Life — Platform end-of-life not assessed — this repository declares no platform this pass reads
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage NOT MEASURED: this repository's test suite is reachable only from an Apple platform — it ships ExcalidrawZ.xcodeproj and no SwiftPM manifest, so it is built by Xcode rather than by `swift test`. The analyzer runs on Linux, where no simulator exists, so the suite was not run and no coverage was instrumented. Not scored. To have the real number read, produce a coverage report in a standard format (lcov — `swift test --enable-code-coverage` (SwiftPM) or `xcodebuild test -scheme <YourScheme> -enableCodeCoverage YES` (an .xcodeproj/.xcworkspace suite), then `xcrun llvm-cov export -format=lcov`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures.
  • DM1 Aggregate boundaries — not scored for Swift: the sidecar flattens array/collection types (a child COLLECTION = legitimate membership vs a single embedded aggregate is indistinguishable), and aggregate-vs-value-object classification cannot be told apart in source (every struct-holding-struct reads alike) — reported as guidance rather than measured
  • DM3 Integration-event coupling — not scored for Swift: a cross-SwiftPM-target domain leak cannot be told apart in source from a legitimate shared-kernel/contracts module, and most repositories ship a single module — reported as guidance rather than measured
  • DM7 Repository granularity — not scored for Swift: 'a repository per CHILD entity' needs the aggregate-root structure, which is not source-resolvable — reported as guidance rather than measured
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • P12 CI test-gate honesty — no CI workflow found
  • P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the JavaScript/TypeScript, Swift source, so there is no service whose uptime a failing dependency could take down
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (lcov — `swift test --enable-code-coverage` (SwiftPM) or `xcodebuild test -scheme <YourScheme> -enableCodeCoverage YES` (an .xcodeproj/.xcworkspace suite), then `xcrun llvm-cov export -format=lcov`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
  • PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for `Benchmark("…")` in a file importing package-benchmark, or package-benchmark in Package.swift, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
  • S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • X2 Cancellation propagation — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X27 Collection changed while being enumerated — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 44 finding(s)
DM2 · Strongly-typed ids · Raw-primitive id despite a typed-id idiom · ×40
  • Raw-primitive id despite a typed-id idiom: ExcalidrawBoundElement.id ExcalidrawZ/Models/ExcalidrawElementBase.swift:43 — `ExcalidrawBoundElement.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: FileLocalizable.fileID ExcalidrawZ/Persistence/File+Persistence.swift:36 — `FileLocalizable.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: FileLocalizable.groupID ExcalidrawZ/Persistence/File+Persistence.swift:37 — `FileLocalizable.groupID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: FileRecord.id ExcalidrawZ/Persistence/SpotlightDelegate.swift:266 — `FileRecord.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: AccountEntry.id ExcalidrawZ/Settings/CloudStorageSettingsView.swift:14 — `AccountEntry.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: FolderChildren.id ExcalidrawZ/Settings/GeneralSettingsView.swift:25 — `FolderChildren.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: RecoveryKeyResetRequest.id ExcalidrawZ/Settings/SecuritySettingsView.swift:826 — `RecoveryKeyResetRequest.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: EditSession.conversationID ExcalidrawZ/Store/AIChatState.swift:146 — `EditSession.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: EditSession.userMessageID ExcalidrawZ/Store/AIChatState.swift:147 — `EditSession.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: TransientError.id ExcalidrawZ/Store/AIChatState.swift:152 — `TransientError.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: TransientError.conversationID ExcalidrawZ/Store/AIChatState.swift:153 — `TransientError.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: TransientError.userMessageID ExcalidrawZ/Store/AIChatState.swift:154 — `TransientError.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: TransientError.retryModelProfileID ExcalidrawZ/Store/AIChatState.swift:158 — `TransientError.retryModelProfileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: CapturedCanvasSaveTarget.id ExcalidrawZ/Store/FileState.swift:408 — `CapturedCanvasSaveTarget.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: AIChatSessionState.conversationID ExcalidrawZ/Store/FileState.swift:1081 — `AIChatSessionState.conversationID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: AIChatSessionState.userMessageID ExcalidrawZ/Store/FileState.swift:1083 — `AIChatSessionState.userMessageID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: AIChatSessionState.preCheckpointID ExcalidrawZ/Store/FileState.swift:1094 — `AIChatSessionState.preCheckpointID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: LockedContentAutomaticUnlockRequest.fileID ExcalidrawZ/Store/LockedContentStateStore.swift:13 — `LockedContentAutomaticUnlockRequest.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: ManagedFileReference.fileID ExcalidrawZ/Store/LockedContentStateStore.swift:48 — `ManagedFileReference.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: SubscriptionItem.id ExcalidrawZ/Subscription/Store_Shared.swift:153 — `SubscriptionItem.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: SubscriptionItem.yearlyID ExcalidrawZ/Subscription/Store_Shared.swift:154 — `SubscriptionItem.yearlyID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: FailedFileInfo.id ExcalidrawZ/Utils/ArchiveFilesModifier.swift:18 — `FailedFileInfo.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: ArchiveFileSnapshot.fileID ExcalidrawZ/Utils/ArchiveFilesModifier.swift:377 — `ArchiveFileSnapshot.fileID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: IdentifiableError.id ExcalidrawZ/Utils/Error.swift:15 — `IdentifiableError.id` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • Raw-primitive id despite a typed-id idiom: Secrets.oneDriveClientID ExcalidrawZ/Utils/Secrets.swift:14 — `Secrets.oneDriveClientID` is a raw primitive id while the repo already defines typed-id wrappers — an inconsistently-adopted typed-id idiom. Give this identity its own typed id so it can't be confused with another entity's id or a plain value.
  • + 15 more in this group — see findings.md.
DM4 · Rich vs anemic domain model · Anemic domain model · ×2
  • Anemic domain model: String ExcalidrawZ/Extensions/String+Extension.swift:10 — `String` is a data-only reference entity whose behaviour is DELEGATED to a foreign utility (static methods that take it as their first parameter and hold its logic) — the anemic domain model. Move the behaviour onto the entity so it enforces its own invariants rather than being driven from outside.
  • Anemic domain model: Group ExcalidrawZ/Persistence/Group+Persistence.swift:12 — `Group` is a data-only reference entity whose behaviour is DELEGATED to a foreign utility (static methods that take it as their first parameter and hold its logic) — the anemic domain model. Move the behaviour onto the entity so it enforces its own invariants rather than being driven from outside.
D10 · Test Quality · Assertions commented out · ×1
  • Assertions commented out: testExample ExcalidrawZUITests/ExcalidrawZUITests.swift:25 — The test body contains commented-out assertion calls and no live one — it runs, verifies nothing, and still passes. Restore the assertions or delete the test; a green test that checks nothing is worse than an absent one.
D10 · Test Quality · Test project verifies nothing · ×1
  • Test project verifies nothing: ExcalidrawZUITests ExcalidrawZUITests/ExcalidrawZUITests.swift:25 — No conventional assertion call was detected in 3 of 3 tests in `ExcalidrawZUITests` — the project as a whole, not one method. 1 of them has its assertions commented out, so this suite did verify conventionally and was switched off — it is not an approval/verifier harness.
Serious — 807 finding(s)
X3 · Exception handling · Swallowed exception (caught, then discarded) · ×35
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Utils/Utils.swift:411 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Utils/Utils.swift:496 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:1647 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Utils/FileSyncCoordinator/FolderMonitor.swift:165 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Store/AIChatState.swift:459 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/SidebarTrailing/Search/SearchInspectorContent.swift:386 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListAllFilesTool.swift:95 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryFileHistoryTool.swift:353 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Sidebar/GroupRowView+DragMove.swift:375 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift:245 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift:118 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift:132 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/Encryption/LockedContentUnlockSession.swift:125 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/CloudStorage/CloudStorageSyncService.swift:286 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageProvider.swift:25 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageProvider.swift:30 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Document.swift:69 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawImageDecoder.swift:150 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawPNGDecoder.swift:59 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawSVGDecoder.swift:53 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/ExcalidrawView/components/FileCoverDiskCache.swift:86 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:436 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/ExcalidrawView/Toolbar/components/MermaidInputSheetView.swift:387 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:134 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:152 — `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • + 10 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×34
  • MethodTooLong: WhatsNewView.allFeaturesList ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:43 — MethodTooLong — allFeaturesList runs 407 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 307 over it, 4.07× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ReadFileTool.simplifyElement ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:375 — MethodTooLong — simplifyElement runs 297 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 197 over it, 2.97× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawRawIcon.path ExcalidrawZ/Sidebar/components/FileRowLabel.swift:138 — MethodTooLong — path runs 265 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 165 over it, 2.65× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawRenderer.canvasView ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:63 — MethodTooLong — canvasView runs 246 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 146 over it, 2.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DrawingSettingsPanel.body ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsPanel.swift:18 — MethodTooLong — body runs 230 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 130 over it, 2.30× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ElementPropertiesPanel.options ExcalidrawZ/ExcalidrawView/components/ElementPropertiesPanel/ElementPropertiesPanel.swift:68 — MethodTooLong — options runs 173 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 73 over it, 1.73× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AdjustElementsMiddleware.patchElement ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:25 — MethodTooLong — patchElement runs 158 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 58 over it, 1.58× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawHomeView.handleActiveGroupChanged ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:277 — MethodTooLong — handleActiveGroupChanged runs 146 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 46 over it, 1.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawCore.userContentController ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:24 — MethodTooLong — userContentController runs 141 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 41 over it, 1.41× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: FileState.performActiveFileChange ExcalidrawZ/Store/FileState.swift:669 — MethodTooLong — performActiveFileChange runs 141 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 41 over it, 1.41× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawLibraryImportSheetView.body ExcalidrawZ/SidebarTrailing/Library/LibraryImportSheetView.swift:129 — MethodTooLong — body runs 140 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 40 over it, 1.40× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MathFunctionPlotWebRenderer.runtimeHTML ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:140 — MethodTooLong — runtimeHTML runs 137 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 37 over it, 1.37× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: OpenURLSheetView.body ExcalidrawZ/ContentView+/Content+OpenFromURL.swift:452 — MethodTooLong — body runs 129 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 29 over it, 1.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: PromptInputView.startSend ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:171 — MethodTooLong — startSend runs 128 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 28 over it, 1.28× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DebugPanelView.cameraSection ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView.swift:106 — MethodTooLong — cameraSection runs 128 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 28 over it, 1.28× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: CloudStorageDocumentStore.replayPendingMetadataOperations ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2303 — MethodTooLong — replayPendingMetadataOperations runs 127 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 27 over it, 1.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AIChatView.messageList ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift:13 — MethodTooLong — messageList runs 125 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 25 over it, 1.25× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: PDFInsertSheet.regularSheetContent ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:105 — MethodTooLong — regularSheetContent runs 124 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 24 over it, 1.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawHomeView.homeLayer ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:106 — MethodTooLong — homeLayer runs 121 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 21 over it, 1.21× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawZApp.body ExcalidrawZ/ExcalidrawZApp.swift:256 — MethodTooLong — body runs 120 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 20 over it, 1.20× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: FileRowDragDropModifier.body ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:107 — MethodTooLong — body runs 118 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 18 over it, 1.18× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ExcalidrawEditor.editorSurface ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:210 — MethodTooLong — editorSurface runs 114 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 14 over it, 1.14× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: FlexibleSplitLayout.placeSubviews ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:76 — MethodTooLong — placeSubviews runs 114 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 14 over it, 1.14× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: NavigateCanvasTool.perform ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:191 — MethodTooLong — perform runs 113 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 13 over it, 1.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ScreenAnnotationView.body ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:42 — MethodTooLong — body runs 108 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 8 over it, 1.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 9 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×29
  • FileTooLong: CloudStorage/CloudStorageDocumentStore.swift ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift — FileTooLong — 2377 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: CloudStorageDocumentStore (15-3292). The bar is 500 significant lines; this is 1877 over it, 4.75× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Store/FileState.swift ExcalidrawZ/Store/FileState.swift — FileTooLong — 1583 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: FileState (16-2433). The bar is 500 significant lines; this is 1083 over it, 3.17× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Bridge/ExcalidrawMCPAppBridge.swift ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift — FileTooLong — 1238 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: ExcalidrawMCPAppBridge (13-1697). The bar is 500 significant lines; this is 738 over it, 2.48× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: AdjustElementsTool/AdjustElementsTool.swift ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift — FileTooLong — 1143 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 643 over it, 2.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift — FileTooLong — 1031 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 531 over it, 2.06× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: Editor/ExcalidrawEditor.swift ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift — FileTooLong — 1013 significant lines (blank, comment-only and punctuation-only lines excluded), about 89% of them inside a single declaration: ExcalidrawEditor (26-1306). The bar is 500 significant lines; this is 513 over it, 2.03× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: components/FileCoverCacheCoordinator.swift ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift — FileTooLong — 821 significant lines (blank, comment-only and punctuation-only lines excluded), about 98% of them inside a single declaration: FileCoverCacheCoordinator (23-1146). The bar is 500 significant lines; this is 321 over it, 1.64× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: AISettings/AISettingsView+MCP.swift ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift — FileTooLong — 734 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 234 over it, 1.47× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: ReadFileTool/ReadFileTool.swift ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift — FileTooLong — 730 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 230 over it, 1.46× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: ElementPropertiesPanel/ElementPropertiesPanel.swift ExcalidrawZ/ExcalidrawView/components/ElementPropertiesPanel/ElementPropertiesPanel.swift — FileTooLong — 719 significant lines (blank, comment-only and punctuation-only lines excluded), about 80% of them inside a single declaration: ElementPropertiesPanel (16-728). The bar is 500 significant lines; this is 219 over it, 1.44× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Toolbar/ExcalidrawToolbar.swift ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift — FileTooLong — 707 significant lines (blank, comment-only and punctuation-only lines excluded), about 75% of them inside a single declaration: ExcalidrawToolbar (18-742). The bar is 500 significant lines; this is 207 over it, 1.41× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Settings/SecuritySettingsView.swift ExcalidrawZ/Settings/SecuritySettingsView.swift — FileTooLong — 679 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 179 over it, 1.36× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: Share/ExportImageView.swift ExcalidrawZ/Share/ExportImageView.swift — FileTooLong — 636 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: ExportImageView (14-796). The bar is 500 significant lines; this is 136 over it, 1.27× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Components/FileHomeItemView.swift ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift — FileTooLong — 634 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 134 over it, 1.27× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: Editor/ExcalidrawEditor+FileStatusObserver.swift ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+FileStatusObserver.swift — FileTooLong — 627 significant lines (blank, comment-only and punctuation-only lines excluded), about 94% of them inside a single declaration: FileStatusObserverModifier (13-874). The bar is 500 significant lines; this is 127 over it, 1.25× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Engine/ExcalidrawDocumentSyncController.swift ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift — FileTooLong — 602 significant lines (blank, comment-only and punctuation-only lines excluded), about 89% of them inside a single declaration: ExcalidrawDocumentSyncController (78-871). The bar is 500 significant lines; this is 102 over it, 1.20× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Toolbar/CompactExcalidrawBottomToolbarContent.swift ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift — FileTooLong — 575 significant lines (blank, comment-only and punctuation-only lines excluded), about 66% of them inside a single declaration: CompactExcalidrawBottomToolbarContent (19-547). The bar is 500 significant lines; this is 75 over it, 1.15× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Toolbar/ExcalidrawEditorToolbarModifier.swift ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift — FileTooLong — 572 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 72 over it, 1.14× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: components/LockedFileAccessSheet.swift ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift — FileTooLong — 562 significant lines (blank, comment-only and punctuation-only lines excluded), about 82% of them inside a single declaration: LockedFileAccessSheet (51-695). The bar is 500 significant lines; this is 62 over it, 1.12× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: Utils/Utils.swift ExcalidrawZ/Utils/Utils.swift — FileTooLong — 559 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 59 over it, 1.12× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: ScreenAnnotation/ScreenAnnotationSession.swift ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift — FileTooLong — 557 significant lines (blank, comment-only and punctuation-only lines excluded), about 94% of them inside a single declaration: ScreenAnnotationSession (9-704). The bar is 500 significant lines; this is 57 over it, 1.11× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: AIChat/AIChatIslandView.swift ExcalidrawZ/SidebarTrailing/AIChat/AIChatIslandView.swift — FileTooLong — 557 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 57 over it, 1.11× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: AdjustElementsTool/AdjustElementsTool+AddOperation.swift ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddOperation.swift — FileTooLong — 553 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 53 over it, 1.11× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: components/AnimatedPresence.swift ExcalidrawZ/components/AnimatedPresence.swift — FileTooLong — 543 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 43 over it, 1.09× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: Optimized/ExcalidrawMCPOptimizedTools.swift ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift — FileTooLong — 532 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 32 over it, 1.06× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×22
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:586 — ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:586-592 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:614-620 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:580 — ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:580-586 | ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:598-604 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/Viewer/ViewerMirrorSession.swift:64 — ExcalidrawZ/ExcalidrawView/Viewer/ViewerMirrorSession.swift:64-70 | ExcalidrawZ/ExcalidrawView/Viewer/ViewerMirrorSession.swift:88-94 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Viewer/ViewerMirrorSession.swift:64` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:772 — ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:772-778 | ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:781-787 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:966 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:966-972 | ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1078-1084 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxConfiguration.swift:18 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxConfiguration.swift:18-24 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveConfiguration.swift:20-26 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxConfiguration.swift:18` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:295 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:295-301 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:390-396 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:345 — ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:345-351 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:366-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:398 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:398-405 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:515-521 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:398` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1072 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1072-1078 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1081-1087 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/AIChatAttachmentMenu.swift:50 — ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/AIChatAttachmentMenu.swift:50-56 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/AIChatAttachmentMenu.swift:73-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/AIChatAttachmentMenu.swift:50` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Utils/Utils.swift:442 — ExcalidrawZ/Utils/Utils.swift:442-448 | ExcalidrawZ/Utils/Utils.swift:530-536 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/Utils.swift:442` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:98 — ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:98-104 | ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:174-181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:111 — ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:111-117 | ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:129-136 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:803 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:803-809 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/AIChatAttachmentMenu.swift:240-246 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:221 — ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:221-227 | ExcalidrawZ/Persistence/Encryption/LockedContentUnlockSupport.swift:381-387 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Settings/SecuritySettingsView.swift:685 — ExcalidrawZ/Settings/SecuritySettingsView.swift:685-691 | ExcalidrawZ/components/RecoveryKeyInputSheet.swift:157-163 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:158 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:158-164 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:105-111 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) ExcalidrawZ/components/Button+/ToolbarCloseButton.swift:13 — ExcalidrawZ/components/Button+/ToolbarCloseButton.swift:13-19 | ExcalidrawZ/components/Button+/ToolbarDismissButton.swift:14-20 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) ExcalidrawZ/ExcalidrawView/MediaItemSyncModifier.swift:89 — ExcalidrawZ/ExcalidrawView/MediaItemSyncModifier.swift:89-95 | ExcalidrawZ/Persistence/FileStorage/FileStorageManager.swift:224-230 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:109 — ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:109-115 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift:90-100 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift` and `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:114 — ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:114-120 | ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:415-421 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×21
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:10 — ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:10-19 | ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_File.swift:10-17 — before extracting anything, compare `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift` and `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_File.swift` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:10` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:184 — ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:184-191 | ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:321-328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:184` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:484 — ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:484-491 | ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:543-550 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:484` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `20` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:11 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:11-18 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrOne.swift:11-18 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:11` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrOne.swift:21` calls `move`, `CGPoint`, `addLine` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:21` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1137 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1137-1144 | ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1164-1171 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:180 — ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:180-187 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:216-223 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:180` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:391 — ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:391-398 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:405-412 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:391` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:145 — ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:145-152 | ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:166-173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Sidebar/GroupsView.swift:239 — ExcalidrawZ/Sidebar/GroupsView.swift:239-246 | ExcalidrawZ/Sidebar/Local/LocalFoldersView.swift:201-208 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/GroupsView.swift:239` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:309 — ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:309-318 | ExcalidrawZ/Sidebar/components/FileContextMenu.swift:301-308 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:309` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:309 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:309-316 | ExcalidrawZ/SidebarTrailing/AIChat/components/ToolCards/AIProposalToolResultCard.swift:304-311 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:74 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:74-81 | ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift:91-98 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:74` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Store/FileState+AIChatSession.swift:391 — ExcalidrawZ/Store/FileState+AIChatSession.swift:391-398 | ExcalidrawZ/Store/FileState+AIChatSession.swift:439-446 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:82 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:82-89 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:68-75 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:82` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:151 — ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:151-158 | ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:197-204 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/components/styles/AIAppearancePalette.swift:66 — ExcalidrawZ/components/styles/AIAppearancePalette.swift:66-73 | ExcalidrawZ/components/styles/AIAppearancePalette.swift:85-92 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/styles/AIAppearancePalette.swift:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:307 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:307-314 | ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift:143-150 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:412 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:412-419 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:658-665 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:539 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:539-546 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:728-735 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageProvider.swift:26 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageProvider.swift:26-33 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageProvider.swift:21-28 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `authenticator` to `any BoxAuthenticating` in one and `any OneDriveAuthenticating` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) ExcalidrawZ/SidebarTrailing/Presentation/PresentationSlideList.swift:176 — ExcalidrawZ/SidebarTrailing/Presentation/PresentationSlideList.swift:176-183 | ExcalidrawZ/SidebarTrailing/Presentation/PresentationStage.swift:125-132 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×19
  • Duplicated block (6 lines × 2) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWelcomeView.swift:72 — ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWelcomeView.swift:72-77 | ExcalidrawZ/SidebarTrailing/Presentation/PresentationWelcomeView.swift:52-57 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWelcomeView.swift:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `14` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:66 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:66-73 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:160-165 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:125 — ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:125-130 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:258-263 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:125` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:92 — ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:92-98 | ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:148-153 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:92` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:434 — ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:434-439 | ExcalidrawZ/Store/FileState.swift:1707-1712 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:434` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:236 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:236-241 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:291-296 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView+Diagnostics.swift:75 — ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView+Diagnostics.swift:75-80 | ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView.swift:364-369 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView+Diagnostics.swift:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Utils/FileSyncCoordinator/OpenInPlaceDocumentSession.swift:83 — ExcalidrawZ/Utils/FileSyncCoordinator/OpenInPlaceDocumentSession.swift:83-88 | ExcalidrawZ/Utils/FileSyncCoordinator/OpenInPlaceDocumentSession.swift:99-104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/FileSyncCoordinator/OpenInPlaceDocumentSession.swift:83` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageSession.swift:71 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageSession.swift:71-76 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:69-74 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Settings/MediaSettings/MediaCleanupSheet.swift:577 — ExcalidrawZ/Settings/MediaSettings/MediaCleanupSheet.swift:577-582 | ExcalidrawZ/Settings/MediaSettings/MediaSettingsDestinationView.swift:38-43 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift:141 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift:141-146 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView.swift:289-294 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:326 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:326-331 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:320-325 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:333 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:333-338 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:327-332 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:340 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:340-345 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:334-339 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:277 — ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:277-282 | ExcalidrawZ/Settings/AISettings/AISettingsView+Loading.swift:13-20 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:102 — ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:102-107 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift:83-88 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift` and `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:122 — ExcalidrawZ/Persistence/Encryption/EncryptedBackupService.swift:122-127 | ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:423-428 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:361 — ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:361-366 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:505-510 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+ResizeOperation.swift:38 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+ResizeOperation.swift:38-43 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+ResizeOperation.swift:46-51 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&item.updated) return .generic(item) case .linear(var` in one and `&item.updated) return .linear(item) case .arrow(var` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D3 · God Classes · ClassTooLong · ×18
  • ClassTooLong: CloudStorageDocumentStore ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:14 — ClassTooLong — 2373 significant lines (blank, comment-only and punctuation-only lines excluded), 120 methods. The bar is 400 significant lines; this is 1973 over it, 5.93× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: FileState ExcalidrawZ/Store/FileState.swift:16 — ClassTooLong — 1576 significant lines (blank, comment-only and punctuation-only lines excluded), 84 methods. The bar is 400 significant lines; this is 1176 over it, 3.94× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExcalidrawMCPAppBridge ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:12 — ClassTooLong — 1231 significant lines (blank, comment-only and punctuation-only lines excluded), 64 methods. The bar is 400 significant lines; this is 831 over it, 3.08× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExcalidrawEditor ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:26 — ClassTooLong — 899 significant lines (blank, comment-only and punctuation-only lines excluded), 28 methods. The bar is 400 significant lines; this is 499 over it, 2.25× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: FileCoverCacheCoordinator ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:22 — ClassTooLong — 804 significant lines (blank, comment-only and punctuation-only lines excluded), 42 methods. The bar is 400 significant lines; this is 404 over it, 2.01× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: FileStatusObserverModifier ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+FileStatusObserver.swift:13 — ClassTooLong — 591 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods. The bar is 400 significant lines; this is 191 over it, 1.48× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExportImageView ExcalidrawZ/Share/ExportImageView.swift:14 — ClassTooLong — 585 significant lines (blank, comment-only and punctuation-only lines excluded), 10 methods. The bar is 400 significant lines; this is 185 over it, 1.46× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ElementPropertiesPanel ExcalidrawZ/ExcalidrawView/components/ElementPropertiesPanel/ElementPropertiesPanel.swift:16 — ClassTooLong — 572 significant lines (blank, comment-only and punctuation-only lines excluded), 14 methods. The bar is 400 significant lines; this is 172 over it, 1.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExcalidrawDocumentSyncController ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:78 — ClassTooLong — 535 significant lines (blank, comment-only and punctuation-only lines excluded), 38 methods. The bar is 400 significant lines; this is 135 over it, 1.34× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExcalidrawToolbar ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:18 — ClassTooLong — 527 significant lines (blank, comment-only and punctuation-only lines excluded), 27 methods. The bar is 400 significant lines; this is 127 over it, 1.32× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ScreenAnnotationSession ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:8 — ClassTooLong — 524 significant lines (blank, comment-only and punctuation-only lines excluded), 32 methods. The bar is 400 significant lines; this is 124 over it, 1.31× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: DebugPanelView ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView.swift:13 — ClassTooLong — 504 significant lines (blank, comment-only and punctuation-only lines excluded), 24 methods. The bar is 400 significant lines; this is 104 over it, 1.26× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: MediaCleanupSheet ExcalidrawZ/Settings/MediaSettings/MediaCleanupSheet.swift:14 — ClassTooLong — 501 significant lines (blank, comment-only and punctuation-only lines excluded), 22 methods. The bar is 400 significant lines; this is 101 over it, 1.25× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: LibraryView ExcalidrawZ/SidebarTrailing/Library/LibraryView.swift:18 — ClassTooLong — 468 significant lines (blank, comment-only and punctuation-only lines excluded), 15 methods. The bar is 400 significant lines; this is 68 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: LockedFileAccessSheet ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift:51 — ClassTooLong — 462 significant lines (blank, comment-only and punctuation-only lines excluded), 17 methods. The bar is 400 significant lines; this is 62 over it, 1.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: PDFInsertSheet ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:40 — ClassTooLong — 448 significant lines (blank, comment-only and punctuation-only lines excluded), 11 methods. The bar is 400 significant lines; this is 48 over it, 1.12× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ExcalidrawHomeView ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:11 — ClassTooLong — 424 significant lines (blank, comment-only and punctuation-only lines excluded), 10 methods. The bar is 400 significant lines; this is 24 over it, 1.06× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Paywall ExcalidrawZ/Subscription/Paywall.swift:16 — ClassTooLong — 405 significant lines (blank, comment-only and punctuation-only lines excluded), 38 methods. The bar is 400 significant lines; this is 5 over it, 1.01× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×18
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:211 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:211-219 | ExcalidrawZ/components/CloudStorageDocumentSyncIndicator.swift:95-103 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:211` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:210` calls `foregroundStyle` and `ExcalidrawZ/components/CloudStorageDocumentSyncIndicator.swift:94` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:19 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:19-27 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+SkeletonHelpers.swift:23-31 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:20 — ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:20-28 | ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_File.swift:18-26 — before extracting anything, compare `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift` and `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_File.swift` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawImageRenderer_CoreData.swift:20` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:273 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:273-281 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:270-278 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:273` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:57 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:57-65 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:78-86 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:57` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:241 — ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:241-249 | ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:384-392 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:241` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:250` calls `warning` and `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:393` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:319 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:319-327 | ExcalidrawZ/SidebarTrailing/AIChat/components/ToolCards/AIProposalToolResultCard.swift:314-322 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:59 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:59-67 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:113-121 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:59` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/ErrorMessageRow.swift:53 — ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/ErrorMessageRow.swift:53-61 | ExcalidrawZ/SidebarTrailing/AIChat/components/PendingQueueView.swift:79-87 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/ErrorMessageRow.swift:53` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/ErrorMessageRow.swift:63` calls `RoundedRectangle`, `stroke`, `opacity` and `ExcalidrawZ/SidebarTrailing/AIChat/components/PendingQueueView.swift:88` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:129 — ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:129-137 | ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:122-131 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Utils/MCP/Runtime/ExcalidrawMCPElementSanitizer.swift:117 — ExcalidrawZ/Utils/MCP/Runtime/ExcalidrawMCPElementSanitizer.swift:117-125 | ExcalidrawZ/Utils/MCP/Runtime/ExcalidrawMCPElementSanitizer.swift:136-144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Runtime/ExcalidrawMCPElementSanitizer.swift:117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/Components/HomeTipsSection.swift:192 — ExcalidrawZ/ContentView+/Detail/Home/Components/HomeTipsSection.swift:192-200 | ExcalidrawZ/components/WhatsNew/WhatsNewSheetView.swift:538-546 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/FileHomeGridContainer.swift:57 — ExcalidrawZ/ContentView+/Detail/Home/FileHomeGridContainer.swift:57-66 | ExcalidrawZ/Sidebar/components/SidebarScrollHoverModifier.swift:56-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:259 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:259-267 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:170-178 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:310 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:310-318 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:228-236 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:529 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:529-537 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:718-726 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:135 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:135-143 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:130-138 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (9 lines × 2) ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:39 — ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:39-47 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:86-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×17
  • Duplicated block (12 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:213 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:213-224 | ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:137-148 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Workspace.swift:135` calls `Capsule`, `fill` and `ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:212` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:362 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:362-373 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:601-612 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:362` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:252 — ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:252-263 | ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:442-453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/PDFInsertSheet.swift:252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:404 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:404-415 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:401-412 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Persistence/Repository/FileRepository.swift:111 — ExcalidrawZ/Persistence/Repository/FileRepository.swift:111-122 | ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:35-46 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Settings/AISettings/AISettingsView+Information.swift:96 — ExcalidrawZ/Settings/AISettings/AISettingsView+Information.swift:96-107 | ExcalidrawZ/SidebarTrailing/AIChat/components/AIEnableConsentSheet.swift:241-252 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/AISettings/AISettingsView+Information.swift:96` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Sidebar/LinkedStorageSidebarSection.swift:75 — ExcalidrawZ/Sidebar/LinkedStorageSidebarSection.swift:75-86 | ExcalidrawZ/Sidebar/Local/LocalFoldersListView.swift:68-79 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/LinkedStorageSidebarSection.swift:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Sidebar/SidebarFileRowSelectionState.swift:23 — ExcalidrawZ/Sidebar/SidebarFileRowSelectionState.swift:23-34 | ExcalidrawZ/Sidebar/SidebarFileRowSelectionState.swift:125-136 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddLabeledShapeOperation.swift:57 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddLabeledShapeOperation.swift:57-68 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddLabeledShapeOperation.swift:88-99 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:266 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:266-277 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/InsertMathTool/InsertMathTool.swift:134-145 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:266` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1443 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1443-1454 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1522-1533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1443` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:137 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:137-148 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:83-94 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:137` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:416 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:416-427 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:424-435 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:416` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Subscription/LLMCreditsRefreshCoordinator.swift:29 — ExcalidrawZ/Subscription/LLMCreditsRefreshCoordinator.swift:29-40 | ExcalidrawZ/Subscription/LLMCreditsRefreshCoordinator.swift:67-78 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Subscription/LLMCreditsRefreshCoordinator.swift:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) ExcalidrawZ/components/ColorPicker/SpectrumColorPicker.swift:142 — ExcalidrawZ/components/ColorPicker/SpectrumColorPicker.swift:142-153 | ExcalidrawZ/components/ColorPicker/SpectrumColorPicker.swift:181-192 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/ColorPicker/SpectrumColorPicker.swift:142` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CollaborationHome/CollaborationRoomsList.swift:64 — ExcalidrawZ/ContentView+/Detail/Home/CollaborationHome/CollaborationRoomsList.swift:64-75 | ExcalidrawZ/Sidebar/Collaboration/CollaborationFileRow.swift:40-51 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (12 lines × 2) ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:387 — ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:387-400 | ExcalidrawZ/components/PDFViewer/PDFViewerSheet.swift:80-91 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:387` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D6 · Cohesion (LCOM4) · Low cohesion · ×17
  • Low cohesion: AIConversationRepository (LCOM4 17) ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:69 — AIConversationRepository's methods fall into 17 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 17 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ExcalidrawCore (LCOM4 9) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift:13 — ExcalidrawCore's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: PersistenceController (LCOM4 8) ExcalidrawZ/Persistence/PersistenceController.swift:12 — PersistenceController's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AIChatState (LCOM4 6) ExcalidrawZ/Store/AIChatState.swift:86 — AIChatState's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ScreenAnnotationSession (LCOM4 6) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:8 — ScreenAnnotationSession's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ExcalidrawMCPAppBridge (LCOM4 6) ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:12 — ExcalidrawMCPAppBridge's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AppDelegate (LCOM4 5) ExcalidrawZ/AppDelegate.swift:91 — AppDelegate's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AIChatPreferences (LCOM4 5) ExcalidrawZ/Store/AIChatPreferences.swift:38 — AIChatPreferences's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: FileState (LCOM4 5) ExcalidrawZ/Store/FileState.swift:16 — FileState's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ExcalidrawIndirectScrollForwarder (LCOM4 5) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:140 — ExcalidrawIndirectScrollForwarder's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: JSONValue (LCOM4 5) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MathImageTypes.swift:71 — JSONValue's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: LockedContentUnlockSession (LCOM4 4) ExcalidrawZ/Persistence/Encryption/LockedContentUnlockSession.swift:10 — LockedContentUnlockSession's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: CursorHostingView (LCOM4 4) ExcalidrawZ/Utils/CursorHoverView/CursorHoverView.swift:13 — CursorHostingView's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Coordinator (LCOM4 4) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:38 — Coordinator's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: NSImage (LCOM4 4) ExcalidrawZ/Extensions/NSImage+Extension.swift:11 — NSImage's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: File (LCOM4 4) ExcalidrawZ/Persistence/File+Persistence.swift:12 — File's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: LocalFolder (LCOM4 4) ExcalidrawZ/Persistence/LocalFolder+Persistence.swift:22 — LocalFolder's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
D3 · God Classes · TooManyMethods · ×15
  • TooManyMethods: ExcalidrawCore ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift:13 — TooManyMethods — 163 methods, declared across 29 files: Helpers/ExcalidrawCore+ExportHelpers.swift (22), ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift (15), ExcalidrawCore/ExcalidrawCore.swift (15), ExcalidrawCore/ExcalidrawCore+Navigation.swift (12), +25 more file(s). The bar is 30 methods; this is 133 over it, 5.43× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: CloudStorageDocumentStore ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:14 — TooManyMethods — 120 methods. The bar is 30 methods; this is 90 over it, 4.00× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: FileState ExcalidrawZ/Store/FileState.swift:16 — TooManyMethods — 84 methods, declared across 3 files: Store/FileState.swift (68), Store/FileState+AIChatSession.swift (13), Store/FileState+History.swift (3). The bar is 30 methods; this is 54 over it, 2.80× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ExcalidrawMCPAppBridge ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:12 — TooManyMethods — 64 methods. The bar is 30 methods; this is 34 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: PromptInputView ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView.swift:177 — TooManyMethods — 57 methods, declared across 6 files: PromptInput/PromptInputView.swift (17), PromptInput/PromptInputView+Send.swift (13), PromptInput/PromptInputView+CompactIOSFloatingInput.swift (12), PromptInput/PromptInputView+ActionBar.swift (9), +2 more file(s). The bar is 30 methods; this is 27 over it, 1.90× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AdjustElementsMiddleware ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:891 — TooManyMethods — 55 methods, declared across 10 files: AdjustElementsTool/AdjustElementsTool.swift (25), AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift (7), AdjustElementsTool/AdjustElementsTool+AddOperation.swift (4), AdjustElementsTool/AdjustElementsTool+MermaidOperation.swift (4), +6 more file(s). The bar is 30 methods; this is 25 over it, 1.83× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AIChatView ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift:16 — TooManyMethods — 53 methods, declared across 8 files: AIChatView/AIChatView+Actions.swift (20), AIChatView/AIChatView+MessageRows.swift (8), AIChatView/AIChatView+MessagePresentation.swift (7), AIChatView/AIChatView+MessageScrollState.swift (7), +4 more file(s). The bar is 30 methods; this is 23 over it, 1.77× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: View ExcalidrawZ/Extensions/ScrollView+Extension.swift:10 — TooManyMethods — 52 methods, declared across 38 files: AISettings/AISettingsView+MCP.swift (4), components/LockedFileAccessSheet.swift (3), MathInput/MathInputStyles.swift (2), Extensions/View+Extension.swift (2), +34 more file(s). The bar is 30 methods; this is 22 over it, 1.73× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: FileCoverCacheCoordinator ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:22 — TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ExcalidrawDocumentSyncController ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:78 — TooManyMethods — 38 methods. The bar is 30 methods; this is 8 over it, 1.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Paywall ExcalidrawZ/Subscription/Paywall.swift:16 — TooManyMethods — 38 methods, declared across 3 files: Subscription/Paywall.swift (24), Subscription/Paywall+CompactIOS.swift (7), Subscription/Paywall+Regular.swift (7). The bar is 30 methods; this is 8 over it, 1.27× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AISettingsView ExcalidrawZ/Settings/AISettings/AISettingsView.swift:13 — TooManyMethods — 36 methods, declared across 8 files: AISettings/AISettingsView+Activity.swift (7), AISettings/AISettingsView+MCP.swift (7), AISettings/AISettingsView+Loading.swift (6), AISettings/AISettingsView+ModelPicker.swift (5), +4 more file(s). The bar is 30 methods; this is 6 over it, 1.20× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: FileRepository ExcalidrawZ/Persistence/Repository/FileRepository.swift:13 — TooManyMethods — 35 methods, declared across 2 files: Repository/FileRepository+LockedContent.swift (19), Repository/FileRepository.swift (16). The bar is 30 methods; this is 5 over it, 1.17× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: LockedContentStateStore ExcalidrawZ/Store/LockedContentStateStore.swift:33 — TooManyMethods — 33 methods. The bar is 30 methods; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ScreenAnnotationSession ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:8 — TooManyMethods — 32 methods. The bar is 30 methods; this is 2 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×14
  • Duplicated block (15 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CloudStorageFolderFileHomeView.swift:118 — ExcalidrawZ/ContentView+/Detail/Home/CloudStorageFolderFileHomeView.swift:118-132 | ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactCloudStorageBrowserView.swift:105-119 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (15 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/Components/HomeTipsSection.swift:174 — ExcalidrawZ/ContentView+/Detail/Home/Components/HomeTipsSection.swift:174-188 | ExcalidrawZ/components/WhatsNew/WhatsNewSheetView.swift:235-249 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/Components/HomeTipsSection.swift:174` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:310 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:310-324 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:553-567 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (15 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:390 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:390-404 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:636-650 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (15 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:73 — ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:73-87 | ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift:1019-1033 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:96 — ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:96-110 | ExcalidrawZ/SidebarTrailing/Library/LibraryView.swift:326-340 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:96` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVServiceIdentity.swift:21 — ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVServiceIdentity.swift:21-35 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVServiceIdentity.swift:37-51 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift:129 — ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift:129-143 | ExcalidrawZ/Persistence/Repository/AIMessageCheckpointLinkRepository.swift:145-159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:247 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:247-261 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:275-289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:247` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:271 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:271-285 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:299-313 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/NavigateCanvasTool/NavigateCanvasTool.swift:271` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:30 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:30-44 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RestoreFileHistoryTool.swift:44-58 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (15 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+InputField.swift:81 — ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+InputField.swift:81-95 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+InputField.swift:111-125 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+InputField.swift:81` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 2) ExcalidrawZ/Store/ExcalidrawFileSortProvider.swift:59 — ExcalidrawZ/Store/ExcalidrawFileSortProvider.swift:59-73 | ExcalidrawZ/Store/ExcalidrawFileSortProvider.swift:91-105 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Store/ExcalidrawFileSortProvider.swift:59` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) ExcalidrawZ/Utils/Utils.swift:395 — ExcalidrawZ/Utils/Utils.swift:395-409 | ExcalidrawZ/Utils/Utils.swift:480-494 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/Utils.swift:395` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×14
  • Duplicated block (13 lines × 2) ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:46 — ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:46-58 | ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/components/CompactFolderItemView.swift:59-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:46` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:59` calls `allowsHitTesting` and `ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/components/CompactFolderItemView.swift:72` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:106 — ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:106-118 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:143-155 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:115 — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:115-127 | ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift:120-132 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:438 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:438-450 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:454-466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:438` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:225 — ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:225-237 | ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:313-325 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:225` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53 — ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53-65 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:89-101 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawImageDecoder.swift:141 — ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawImageDecoder.swift:141-153 | ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Document.swift:60-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:49 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:49-61 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:160-172 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:49` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:88 — ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:88-100 | ExcalidrawZ/Persistence/Repository/CollaborationFileRepository.swift:269-281 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:88` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:42 — ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:42-54 | ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:71-83 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:85` calls `warning` and `ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:55` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:64 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:64-76 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:67-79 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:64` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Utils/ICloudFileKit/FileCoordinator.swift:188 — ExcalidrawZ/Utils/ICloudFileKit/FileCoordinator.swift:188-200 | ExcalidrawZ/Utils/ICloudFileKit/FileCoordinator.swift:350-362 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/ICloudFileKit/FileCoordinator.swift:188` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:555 — ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:555-567 | ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamToolHandler.swift:61-73 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:555` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:76 — ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:76-88 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift:57-69 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift` and `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D15 · Churn × Complexity Hotspots · Hotspot · ×13
  • Hotspot: ExcalidrawZ/Store/FileState.swift ExcalidrawZ/Store/FileState.swift:669 — ExcalidrawZ/Store/FileState.swift changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 45 in FileState.performActiveFileChange at line 669. 1 of those changes was a fix/bug commit, and the other 9 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/Store/FileState.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:515 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in FileHomeItemContentView.content at line 515. 1 of those changes was a fix/bug commit, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:1198 — ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in ExcalidrawEditor.persistCanvasUpdate at line 1198. 3 of those changes were fix/bug commits, and the other 9 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:839 — ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in FileCoverCacheCoordinator.generate at line 839. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2303 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 26 in CloudStorageDocumentStore.replayPendingMetadataOperations at line 2303. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:143 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 27 in FileHomeItemTransitionModifier.body at line 143. 1 of those changes was a fix/bug commit, and the other 3 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:42 — ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 26 in ScreenAnnotationView.body at line 42. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/Share/ShareToolbarButton.swift ExcalidrawZ/Share/ShareToolbarButton.swift:145 — ExcalidrawZ/Share/ShareToolbarButton.swift changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in ShareToolbarButton.performShareFile at line 145. 1 of those changes was a fix/bug commit, and the other 4 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/Share/ShareToolbarButton.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/AppDelegate.swift ExcalidrawZ/AppDelegate.swift:121 — ExcalidrawZ/AppDelegate.swift changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in AppDelegate.scheduleTerminationSheetIfNeeded at line 121. 1 of those changes was a fix/bug commit, and the other 4 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/AppDelegate.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift:27 — ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in HomeFolderItemView.body at line 27. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:216 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in ExcalidrawDocumentSyncController.load at line 216. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:87 — ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in ScreenAnnotationSession.prepareCanvas at line 87. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift:225 — ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in ScreenAnnotationSaveConfiguration.init at line 225. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×13
  • Duplicated block (11 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:159 — ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:159-169 | ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:213-223 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:159` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:372 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:372-382 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:616-626 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:372` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:18 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:18-28 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrOne.swift:21-31 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrOne.swift:18` calls `move`, `CGPoint`, `addLine` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:16` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1702 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1702-1712 | ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1749-1759 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1702` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:184 — ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:184-194 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:288-298 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:56 — ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:56-66 | ExcalidrawZ/Sidebar/Temporary/TemporaryGroupContextMenu.swift:86-98 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:56` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:196 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:196-206 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:69-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:196` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:99 — ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:99-109 | ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:140-150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:99` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamElementResolver.swift:118 — ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamElementResolver.swift:118-128 | ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamToolHandler.swift:183-193 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:168 — ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:168-178 | ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:191-201 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitLayout.swift:168` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:400 — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:400-410 | ExcalidrawZ/Settings/SecuritySettingsView.swift:414-424 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:107 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:107-117 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:93-103 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:90 — ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:90-100 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift:71-81 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift` and `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveCloudStorageSession.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×13
  • Duplicated block (10 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:609 — ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:609-618 | ExcalidrawZ/components/NewGroupButton.swift:44-53 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:609` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentProgrammaticSnapshotCommitter.swift:70 — ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentProgrammaticSnapshotCommitter.swift:70-79 | ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:213-222 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentProgrammaticSnapshotCommitter.swift:70` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:223` calls `debug` and `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentProgrammaticSnapshotCommitter.swift:80` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:14 — ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:14-23 | ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:29-38 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:14` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:13` calls `padding` and `ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputStyles.swift:28` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Persistence.swift:91 — ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Persistence.swift:91-100 | ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:212-221 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:305 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:305-314 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:226-235 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Persistence/CloudStorage/CloudStorageFolderPicker.swift:176 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageFolderPicker.swift:176-185 | ExcalidrawZ/Persistence/CloudStorage/CloudStorageFolderPicker.swift:230-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/CloudStorageFolderPicker.swift:176` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `16` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:285 — ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:285-294 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:313-322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:285` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFolderRowView.swift:51 — ExcalidrawZ/Sidebar/Local/LocalFolderRowView.swift:51-60 | ExcalidrawZ/Sidebar/Local/LocalFoldersView.swift:90-99 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFolderRowView.swift:51` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:200 — ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:200-209 | ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:555-564 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:200` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:247 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:247-256 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:158-167 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) ExcalidrawZ/Settings/SettingsViewModifier.swift:69 — ExcalidrawZ/Settings/SettingsViewModifier.swift:69-78 | ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift:257-266 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/SettingsViewModifier.swift:69` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) ExcalidrawZ/SidebarTrailing/Library/LibraryItemView.swift:181 — ExcalidrawZ/SidebarTrailing/Library/LibraryItemView.swift:181-190 | ExcalidrawZ/SidebarTrailing/Presentation/PresentationInspectorContent.swift:58-67 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:173 — ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:173-182 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:46-55 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×12
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxConfiguration.swift:25 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxConfiguration.swift:25-29 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveConfiguration.swift:25-29 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxConfiguration.swift:25` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveConfiguration.swift:30` calls `callbackScheme`, `URL` and `ExcalidrawZ/Persistence/CloudStorage/Box/BoxConfiguration.swift:30` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:270 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:270-274 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:374-378 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:110 — ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:110-114 | ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:164-168 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:110` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:136 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:136-140 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:251-255 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:136` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/PersistenceController.swift:243 — ExcalidrawZ/Persistence/PersistenceController.swift:243-247 | ExcalidrawZ/Persistence/PersistenceController.swift:249-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Persistence/PersistenceController.swift:263 — ExcalidrawZ/Persistence/PersistenceController.swift:263-267 | ExcalidrawZ/Persistence/PersistenceController.swift:269-273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (5 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:357 — ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:357-361 | ExcalidrawZ/Sidebar/components/GroupContextMenu.swift:543-547 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:357` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1050 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1050-1054 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1058-1062 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:116 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:116-120 | ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift:125-129 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:116` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:451 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:451-458 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:408-412 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:451` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:329 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:329-333 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:360-364 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:329` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:260 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:260-264 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:318-322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D35 · Change Coupling · Change coupling · ×11
  • Change coupling: CompactAIChatInputOverlay.swift ↔ CompactExcalidrawBottomToolbarContent.swift ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift:1 — `ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift` and `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift` change together 70% of the time (7 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `e8a956be` Polish AI chat input and prep 2.2.6; `86b02f2f` Keep compact AI input visible on approval; `56ac7683` Refactor compact AI chat overlays and AnimatedPresence — run `git show` on any of them.
  • Change coupling: ContentView.swift ↔ ExportFileView.swift ExcalidrawZ/ContentView.swift:1 — `ExcalidrawZ/ContentView.swift` and `ExcalidrawZ/Share/ExportFileView.swift` change together 64% of the time (9 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `55939e10` Refine macOS termination handling; `35f13eab` Fix share file sheet bug in macOS 14; `c08b4d88` update i18n variables inserted in code — run `git show` on any of them.
  • Change coupling: ExportFileView.swift ↔ ExportImageView.swift ExcalidrawZ/Share/ExportFileView.swift:1 — `ExcalidrawZ/Share/ExportFileView.swift` and `ExcalidrawZ/Share/ExportImageView.swift` change together 64% of the time (9 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `35f13eab` Fix share file sheet bug in macOS 14; `15504394` prepare for iOS; `429b7fe8` fix bugs — run `git show` on any of them.
  • Change coupling: CompactAIChatInputOverlay.swift ↔ ExcalidrawEditor.swift ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift:1 — `ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift` and `ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `e8a956be` Polish AI chat input and prep 2.2.6; `56ac7683` Refactor compact AI chat overlays and AnimatedPresence; `d47af8bf` Add toolbar layout policy and use containerSize — run `git show` on any of them.
  • Change coupling: AIChatView+Messages.swift ↔ AssistantRoundView.swift ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift:1 — `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `66ef93c7` iOS compatible; `92a6d0a2` AI chat: add invocation context & loading UI; `7c1112c1` Add chat scroll configuration and loading slot — run `git show` on any of them.
  • Change coupling: AIChatIslandView.swift ↔ AIChatView.swift ExcalidrawZ/SidebarTrailing/AIChat/AIChatIslandView.swift:1 — `ExcalidrawZ/SidebarTrailing/AIChat/AIChatIslandView.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `b3b156ce` Add native viewport insets and AI chat attachments; `8ce804db` Adapt inspectors and AI chat UI for compact iOS; `d6650d31` Improve AI chat ticker & adjust tool output — run `git show` on any of them.
  • Change coupling: FileHomeItemView.swift ↔ FileHomeView.swift ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:1 — `ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift` and `ExcalidrawZ/ContentView+/Detail/Home/FileHomeView.swift` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `7f1e570a` Persist file covers and reduce file browser update work; `d17656a9` Polish imports and loading behavior; `95dd3272` Batch file delete + selection & UI refinements — run `git show` on any of them.
  • Change coupling: ExcalidrawEditor.swift ↔ PromptInputView.swift ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:1 — `ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView.swift` change together 50% of the time (6 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `e8a956be` Polish AI chat input and prep 2.2.6; `61b5c5cf` Improve AI chat UI, sync controller & file handling; `3783c790` Optimize AI chat image attachments & UI — run `git show` on any of them.
  • Change coupling: ContentView.swift ↔ AboutView.swift ExcalidrawZ/ContentView.swift:1 — `ExcalidrawZ/ContentView.swift` and `ExcalidrawZ/Settings/AboutView.swift` change together 50% of the time (6 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `35f13eab` Fix share file sheet bug in macOS 14; `855af95d` opt paywall for non-appstore version; `4011869c` opt toolbar — run `git show` on any of them.
  • Change coupling: LibraryItemView.swift ↔ LibraryView.swift ExcalidrawZ/SidebarTrailing/Library/LibraryItemView.swift:1 — `ExcalidrawZ/SidebarTrailing/Library/LibraryItemView.swift` and `ExcalidrawZ/SidebarTrailing/Library/LibraryView.swift` change together 50% of the time (6 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `6f15ac84` Add library preview system & preview export helpers; `a5561953` Add lasso tool, box selection & edit library UI (at that commit the files were still `ExcalidrawZ/Sidebar/Library/LibraryItemView.swift` and `ExcalidrawZ/Sidebar/Library/LibraryView.swift`); `c08b4d88` update i18n variables inserted in code (at that commit the files were still `ExcalidrawZ/Sidebar/Library/LibraryItemView.swift` and `ExcalidrawZ/Sidebar/Library/LibraryView.swift`) — run `git show` on any of them.
  • Change coupling: GroupListView.swift ↔ LocalFilesListView.swift ExcalidrawZ/Sidebar/GroupListView.swift:1 — `ExcalidrawZ/Sidebar/GroupListView.swift` and `ExcalidrawZ/Sidebar/Local/LocalFilesListView.swift` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `6a9af38e` Pause sidebar hover effects while scrolling; `fbe356c6` Add sidebar scroll-to-active-file on iOS; `18c3cecf` opt sortfield — run `git show` on any of them.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×10
  • Duplicated block (16 lines × 2) ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:350 — ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:350-365 | ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:398-413 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Encryption/EncryptedContentEnvelope.swift:350` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:203 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:203-218 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:319-334 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:203` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:37 — ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:37-52 | ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:100-115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:37` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Settings/GeneralSettingsView.swift:113 — ExcalidrawZ/Settings/GeneralSettingsView.swift:113-128 | ExcalidrawZ/Settings/GeneralSettingsView.swift:134-149 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/GeneralSettingsView.swift:113` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Settings/components/DisableICloudSyncingModifier.swift:37 — ExcalidrawZ/Settings/components/DisableICloudSyncingModifier.swift:37-52 | ExcalidrawZ/Settings/components/DisableICloudSyncingModifier.swift:72-87 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/components/DisableICloudSyncingModifier.swift:37` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Sidebar/components/FileContextMenu.swift:146 — ExcalidrawZ/Sidebar/components/FileContextMenu.swift:146-161 | ExcalidrawZ/Sidebar/components/FileContextMenu.swift:168-183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:59 — ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:59-74 | ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:258-273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `file` to `FileState.ActiveFile?` in one and `file` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (16 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AICameraDirector.swift:154 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AICameraDirector.swift:154-169 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AICameraDirector.swift:195-210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AICameraDirector.swift:154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:296 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:296-311 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:262-277 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:296` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) ExcalidrawZ/Store/FileState+AIChatSession.swift:406 — ExcalidrawZ/Store/FileState+AIChatSession.swift:406-421 | ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:692-707 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Store/FileState+AIChatSession.swift:406` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×9
  • Duplicated block (17 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:131 — ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:131-147 | ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:187-203 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:131` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:44 — ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:44-60 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:111-127 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:44` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:88 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:88-104 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:109-125 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:88` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `configuration` to `BoxConfiguration` in one and `DropboxConfiguration` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (17 lines × 2) ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:321 — ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:321-337 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveFileManager.swift:479-495 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:321` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFilesListView.swift:36 — ExcalidrawZ/Sidebar/Local/LocalFilesListView.swift:36-52 | ExcalidrawZ/Sidebar/Temporary/TemporaryFileListView.swift:28-44 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFilesListView.swift:36` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:20 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:20-36 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:20-36 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:976 — ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:976-992 | ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:1056-1072 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:976` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 2) ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:64 — ExcalidrawZ/Utils/MathRendering/LatexMathWebRenderer.swift:64-80 | ExcalidrawZ/Utils/MathRendering/MathFunctionPlotWebRenderer.swift:50-66 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
  • Duplicated block (17 lines × 2) ExcalidrawZ/SidebarTrailing/CanvasSettings/CanvasSettingsInspectorContent.swift:54 — ExcalidrawZ/SidebarTrailing/CanvasSettings/CanvasSettingsInspectorContent.swift:54-70 | ExcalidrawZ/SidebarTrailing/Search/SearchInspectorContent.swift:78-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×9
  • Duplicated block (14 lines × 2) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:979 — ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:979-992 | ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1195-1208 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:979` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:364 — ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:364-377 | ExcalidrawZ/Sidebar/components/GroupContextMenu.swift:550-563 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:364` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:407 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:407-420 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:430-443 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:407` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:190 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:190-203 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:593-606 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:190` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) ExcalidrawZ/Subscription/Paywall+CompactIOS.swift:74 — ExcalidrawZ/Subscription/Paywall+CompactIOS.swift:74-87 | ExcalidrawZ/Subscription/Paywall+Regular.swift:121-134 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (14 lines × 2) ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:256 — ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:256-269 | ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:311-324 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:256` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:281 — ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:281-294 | ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:330-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:281` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:280` calls `appInfo` and `ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:329` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:90 — ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:90-103 | ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:134-147 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:90` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+NativeEyeDropper.swift:226 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+NativeEyeDropper.swift:226-239 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveMSALAuthenticator.swift:239-252 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D17 · Explicit Debt · TodoComment · ×8
  • TodoComment ExcalidrawZ/components/NewFileButton.swift:70 — // TODO: Temp, change it next version. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/Subscription/Store_Shared.swift:218 — // TODO: add a localized key for this reason. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatErrorPresenter.swift:23 — /// driven by intent, not server phrasing. (TODO: route credits / — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatErrorPresenter.swift:50 — // TODO: open sign-in sheet once an entry point lands. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/Settings/SettingsView.swift:249 — // TODO: localize once a key is added. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:117 — // TODO: migrate to excalidrawZHelper — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:120 — // TODO: migrate to excalidrawZHelper — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment ExcalidrawZ/ContentView+/Detail/ContentViewDetail.swift:30 — // TODO: Not Good Enough — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×7
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:51 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:51-64 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:77-90 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:24-38 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ViewportHelpers.swift:132-142 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:62 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:62-80 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:11-31 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:33-51 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+SkeletonHelpers.swift:11-35 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:265 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:265-278 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:306-329 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:358-381 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:415-427 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:65 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:65-79 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:63-75 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:69-81 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:82-94 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:81 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:81-100 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:77-94 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:83-100 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:96-113 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:104 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:104-218 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:220-334 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:336-436 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:438-552 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:190 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:190-206 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:593-608 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:63-79 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:65-83 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D12 · Dependency Hygiene · Floating branch dependency · ×6
  • Floating branch dependency: alerttoast — Dependency `alerttoast` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `master` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
  • Floating branch dependency: chocofordkit — Dependency `chocofordkit` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `main` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
  • Floating branch dependency: llmcore — Dependency `llmcore` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `main` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
  • Floating branch dependency: llmkit — Dependency `llmkit` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `dev` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
  • Floating branch dependency: openai — Dependency `openai` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `main` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
  • Floating branch dependency: swiftyalert — Dependency `swiftyalert` is resolved in ExcalidrawZ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved against branch `dev` rather than a released version — the project pins no immutable point, so resolving the packages again moves this dependency to whatever that branch holds at the time. Change the dependency rule in Xcode to a version requirement, or to an exact commit.
D10 · Test Quality · No assertions · ×5
  • No assertions: testPerformanceOfEncoding ExcalidrawZTests/ExcalidrawFileTests.swift:308 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testPerformanceBatchCreateFiles ExcalidrawZTests/PersistenceTests.swift:325 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testPerformanceFetchManyFiles ExcalidrawZTests/PersistenceTests.swift:344 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testLaunchPerformance ExcalidrawZUITests/ExcalidrawZUITests.swift:33 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: testLaunch ExcalidrawZUITests/ExcalidrawZUITestsLaunchTests.swift:20 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×5
  • Duplicated block (10 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:337 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:337-346 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:364-373 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:363-372 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:337` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:287 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:287-296 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:309-318 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:414-423 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:133 — ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:133-142 | ExcalidrawZ/Sidebar/Temporary/TemporaryGroupContextMenu.swift:36-45 | ExcalidrawZ/Sidebar/components/FileContextMenu.swift:405-414 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:133` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:195 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:195-204 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:598-607 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:68-77 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:195` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:109 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:109-119 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:115-124 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:128-137 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×5
  • Duplicated block (5 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:239 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:239-243 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:280-284 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:325-329 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:239` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:147 — ExcalidrawZ/Utils/ArchiveFilesModifier.swift:147-151 | ExcalidrawZ/Utils/ArchiveFilesModifier.swift:344-348 | ExcalidrawZ/Utils/ArchiveFilesModifier.swift:495-499 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:103 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:103-107 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:109-113 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:122-126 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:121 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:121-125 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:126-130 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:139-143 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:265 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:265-269 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:306-310 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:358-362 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:265` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
X3 · Exception handling · Swallowed exception (empty catch) · ×5
  • Swallowed exception (empty catch) ExcalidrawZ/Utils/FileSyncCoordinator/LocalFolder+FileSyncCoordinator.swift:21 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) ExcalidrawZ/Store/AppPreference.swift:171 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) ExcalidrawZ/Store/FileState.swift:789 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) ExcalidrawZ/Store/ToolState.swift:523 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) ExcalidrawZ/Store/ToolState.swift:569 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×4
  • Duplicated block (21 lines × 2) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:259 — ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:259-279 | ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:303-323 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:259` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) ExcalidrawZ/Persistence/iCloudDrive/MediaItem+iCloudDrive.swift:19 — ExcalidrawZ/Persistence/iCloudDrive/MediaItem+iCloudDrive.swift:19-39 | ExcalidrawZ/Persistence/iCloudDrive/MediaItem+iCloudDrive.swift:88-108 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/iCloudDrive/MediaItem+iCloudDrive.swift:19` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:525 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:525-545 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:391-411 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:525` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (21 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:238 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:238-258 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:330-350 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×4
  • Duplicated block (20 lines × 2) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:30 — ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:30-49 | ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:101-120 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:30` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift:347 — ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift:347-366 | ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift:709-728 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/AISettings/AISettingsView+MCP.swift:347` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) ExcalidrawZ/Share/ExportImageView.swift:510 — ExcalidrawZ/Share/ExportImageView.swift:510-529 | ExcalidrawZ/Share/ExportImageView.swift:579-598 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Share/ExportImageView.swift:510` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:335 — ExcalidrawZ/Utils/ArchiveFilesModifier.swift:335-354 | ExcalidrawZ/Utils/ArchiveFilesModifier.swift:486-505 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/ArchiveFilesModifier.swift:335` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×4
  • Duplicated block (19 lines × 2) ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:60 — ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:60-78 | ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:123-141 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:60` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) ExcalidrawZ/Share/ShareView.swift:140 — ExcalidrawZ/Share/ShareView.swift:140-158 | ExcalidrawZ/components/WhatsNew/WhatsNewSheetView.swift:156-174 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Share/ShareView.swift:140` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:376 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:376-394 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:383-401 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:376` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:311 — ExcalidrawZ/Utils/ArchiveFilesModifier.swift:311-329 | ExcalidrawZ/Utils/ArchiveFilesModifier.swift:463-481 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/ArchiveFilesModifier.swift:311` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×4
  • Duplicated block (18 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:182 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:182-199 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:298-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:182` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:154 — ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:154-171 | ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:200-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:154` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:569 — ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:569-586 | ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamToolHandler.swift:75-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:569` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Utils/MCP/UpstreamCompat/ExcalidrawMCPUpstreamToolHandler.swift:93` calls `cameraAspectRatioHint` and `ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:587` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) ExcalidrawZ/ExcalidrawView/MediaItemSyncModifier.swift:36 — ExcalidrawZ/ExcalidrawView/MediaItemSyncModifier.swift:36-53 | ExcalidrawZ/Persistence/FileStorage/FileStorageManager.swift:170-187 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×4
  • Duplicated block (12 lines × 3) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:67 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:67-78 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:16-27 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MermaidHelpers.swift:38-49 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (12 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:92 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:92-103 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:113-124 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:82-93 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:92` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `configuration` to `BoxConfiguration` in one and `DropboxConfiguration` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12 lines × 3) ExcalidrawZ/Persistence/iCloudDrive/CollaborationFile+iCloudDrive.swift:18 — ExcalidrawZ/Persistence/iCloudDrive/CollaborationFile+iCloudDrive.swift:18-29 | ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:19-30 | ExcalidrawZ/Persistence/iCloudDrive/FileCheckpoint+iCloudDrive.swift:19-30 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/iCloudDrive/CollaborationFile+iCloudDrive.swift:18` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:123 — ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:123-134 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:170-181 | ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:217-228 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/iCloudDrive/iCloudDriveDataMigrator.swift:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×4
  • Duplicated block (11 lines × 3) ExcalidrawZ/Settings/SecuritySettingsView.swift:939 — ExcalidrawZ/Settings/SecuritySettingsView.swift:939-949 | ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift:440-450 | ExcalidrawZ/components/RecoveryKeyInputSheet.swift:177-187 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/SecuritySettingsView.swift:939` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:96 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:96-106 | ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:270-280 | ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift:105-115 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:96` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/Tools/CalculatorTool.swift:21 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/CalculatorTool.swift:21-31 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/FinalAnswerTool.swift:21-31 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/WebFetchTool.swift:20-30 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (11 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:22 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:22-32 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:19-29 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:23-33 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×4
  • Duplicated block (9 lines × 3) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:84 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:84-92 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:96-104 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:108-116 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 3) ExcalidrawZ/Persistence/FileStorage/FileStorageTypes.swift:123 — ExcalidrawZ/Persistence/FileStorage/FileStorageTypes.swift:123-131 | ExcalidrawZ/Persistence/FileStorage/FileStorageTypes.swift:136-144 | ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:343-351 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/FileStorage/FileStorageTypes.swift:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCloudStorageProvider.swift:28 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCloudStorageProvider.swift:28-36 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageProvider.swift:40-48 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCloudStorageProvider.swift:24-32 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `authenticator` to `any DropboxAuthenticating` in one and `any GoogleDriveAuthenticating` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:25 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:25-33 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:27-35 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:27-35 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `configuration` to `BoxConfiguration` in one and `DropboxConfiguration` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:39` calls `filter` and `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:37` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×4
  • Duplicated block (8 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:304 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:304-311 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:331-338 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:225-232 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:304` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:312` calls `setValue` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:339` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/CompactRows.swift:93 — ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/CompactRows.swift:93-100 | ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/ErrorMessageRow.swift:52-59 | ExcalidrawZ/SidebarTrailing/AIChat/components/PendingQueueView.swift:78-85 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/CompactRows.swift:93` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/CompactRows.swift:102` calls `RoundedRectangle`, `stroke` and `ExcalidrawZ/SidebarTrailing/AIChat/components/PendingQueueView.swift:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:323 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:323-330 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:725-732 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:289-296 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:390 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:390-397 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:734-741 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:349-356 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×4
  • Duplicated block (7 lines × 3) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:442 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:442-448 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:458-464 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:491-497 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:442` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 3) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:287 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:287-293 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:338-344 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:390-396 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:287` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:125 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:125-131 | ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:296-302 | ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift:133-139 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift:129` calls `joined` and `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:292` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:207 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:207-213 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:230-236 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:322-328 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×3
  • Duplicated block (14–15 lines × 2) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:719 — ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:719-733 | ExcalidrawZ/SidebarTrailing/Library/LibraryItemPreviewCoordinator.swift:145-158 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:719` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) ExcalidrawZ/Persistence/Repository/CollaborationFileRepository.swift:495 — ExcalidrawZ/Persistence/Repository/CollaborationFileRepository.swift:495-509 | ExcalidrawZ/Persistence/Repository/FileRepository.swift:711-724 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/CollaborationFileRepository.swift:495` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–15 lines × 2) ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:428 — ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:428-442 | ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:446-459 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:428` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `version` to `"v1.4.4"` in one and `"v1.4.1"` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×3
  • Duplicated block (10–13 lines × 2) ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:290 — ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:290-299 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:477-489 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10–13 lines × 2) ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:83 — ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:83-92 | ExcalidrawZ/Persistence/Repository/FileRepository.swift:476-488 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:83` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10–13 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:227 — ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:227-239 | ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:443-452 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:227` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×3
  • Duplicated block (11–12 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:134 — ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:134-144 | ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:151-162 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:134` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:112 — ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:112-122 | ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:245-256 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentAppStateSnapshotSaver.swift:112` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:77 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:77-88 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:403-413 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:77` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D15 · Churn × Complexity Hotspots · Repeated repair · ×2
  • Repeated repair: ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:107 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is ExcalidrawWebView.keyDown at line 107), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “Fix SwiftUI update cycle when closing canvas”; “Fix macOS canvas sizing and toolbar hit testing”; “fix: prevent dropped library payload from navigating canvas”; “fix: stuck loading when draging items onto the canvas”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift:160 — ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is LocalFilesProvider.getFolderContents at line 160), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “Fix editor recovery and document export compatibility”; “Fix local file access and cloud refresh”; “Fix local file/folder move operations (v2.2.9)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-20..2026-10-18, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-20 18:54:27 +08:00' --until='2026-10-18 18:54:27 +08:00' --full-history --no-merges -- ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (7 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11-25 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOneOrMany.swift:11-25 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadDiamond.swift:11-23 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangle.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangleOutline.swift:11-22 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:138-403 | ExcalidrawZ/Store/ToolState.swift:589-602 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) ExcalidrawZ/Models/ExcalidrawElement.swift:83 — ExcalidrawZ/Models/ExcalidrawElement.swift:83-106 | ExcalidrawZ/Models/ExcalidrawElement.swift:110-133 | ExcalidrawZ/Models/ExcalidrawElement.swift:135-158 | ExcalidrawZ/Models/ExcalidrawElement.swift:160-183 | ExcalidrawZ/Models/ExcalidrawElement.swift:185-208 | ExcalidrawZ/Models/ExcalidrawElement.swift:210-233 | ExcalidrawZ/Models/ExcalidrawElement.swift:235-258 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×2
  • Duplicated block (26 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1406 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1406-1431 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:1487-1512 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (26 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:435 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:435-460 | ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:458-483 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×2
  • Duplicated block (16–17 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:164 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:164-180 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:281-296 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:164` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16–17 lines × 2) ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:61 — ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:61-77 | ExcalidrawZ/Utils/Migration/MigrateToNewVersion.swift:65-80 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Subscription/components/SwitchAppStoreVersionView.swift:61` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×2
  • Duplicated block (15–16 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:452 — ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:452-466 | ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:480-495 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:452` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:695 — ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:695-709 | ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:719-734 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×2
  • Duplicated block (13–15 lines × 2) ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Persistence.swift:25 — ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile+Persistence.swift:25-37 | ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:195-209 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13–15 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:356 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:356-368 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:265-279 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:356` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:355` calls `permissionDenied` and `ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:264` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×2
  • Duplicated block (14 lines × 3) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:38 — ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:38-51 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:74-87 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:105-118 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageSession.swift:21 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCloudStorageSession.swift:21-34 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCloudStorageSession.swift:20-33 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:19-32 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCloudStorageSession.swift:17` calls `DropboxItemPathIndex` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCloudStorageSession.swift:18` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×2
  • Duplicated block (10–11 lines × 2) ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:240 — ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:240-249 | ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:271-281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/CheckpointRepository.swift:240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10–11 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/DateTimeTool.swift:21 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/DateTimeTool.swift:21-31 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:80-89 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/DateTimeTool.swift:21` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×2
  • Duplicated block (9–10 lines × 2) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:324 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:324-332 | ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift:92-101 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:324` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:148 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:148-156 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:263-272 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:148` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×2
  • Duplicated block (8–9 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:336 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:336-344 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadCanvasImageTool.swift:128-135 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:336` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:252 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:252-259 | ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:328-336 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×2
  • Duplicated block (6 lines × 3) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:590 — ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:590-595 | ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:772-777 | ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:781-786 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift:423 — ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift:423-428 | ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift:450-455 | ExcalidrawZ/Persistence/Repository/FileRepository.swift:305-310 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
D1 · Cyclomatic Complexity · ExcalidrawCore.userContentController (cyclomatic 49) · ×1
  • ExcalidrawCore.userContentController (cyclomatic 49) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:24 — ExcalidrawCore.userContentController has cyclomatic complexity 49 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · AdjustElementsMiddleware.patchElement (cyclomatic 48) · ×1
  • AdjustElementsMiddleware.patchElement (cyclomatic 48) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:25 — AdjustElementsMiddleware.patchElement has cyclomatic complexity 48 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileState.performActiveFileChange (cyclomatic 45) · ×1
  • FileState.performActiveFileChange (cyclomatic 45) ExcalidrawZ/Store/FileState.swift:669 — FileState.performActiveFileChange has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ViewerLocalConnection.update (cyclomatic 40) · ×1
  • ViewerLocalConnection.update (cyclomatic 40) ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift:77 — ViewerLocalConnection.update has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DrawingSettingsPanel.body (cyclomatic 37) · ×1
  • DrawingSettingsPanel.body (cyclomatic 37) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsPanel.swift:18 — DrawingSettingsPanel.body has cyclomatic complexity 37 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · FileHomeItemContentView.content (cyclomatic 35) · ×1
  • FileHomeItemContentView.content (cyclomatic 35) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:515 — FileHomeItemContentView.content has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawRenderer.canvasView (cyclomatic 34) · ×1
  • ExcalidrawRenderer.canvasView (cyclomatic 34) ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:63 — ExcalidrawRenderer.canvasView has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawArrowElement.== (cyclomatic 33) · ×1
  • ExcalidrawArrowElement.== (cyclomatic 33) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:571 — ExcalidrawArrowElement.== has cyclomatic complexity 33 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ExcalidrawTextElement.== (cyclomatic 32) · ×1
  • ExcalidrawTextElement.== (cyclomatic 32) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:141 — ExcalidrawTextElement.== has cyclomatic complexity 32 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ExcalidrawHomeView.homeLayer (cyclomatic 32) · ×1
  • ExcalidrawHomeView.homeLayer (cyclomatic 32) ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:106 — ExcalidrawHomeView.homeLayer has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileRowDragDropModifier.sortFiles (cyclomatic 31) · ×1
  • FileRowDragDropModifier.sortFiles (cyclomatic 31) ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:268 — FileRowDragDropModifier.sortFiles has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileCoverCacheCoordinator.generate (cyclomatic 30) · ×1
  • FileCoverCacheCoordinator.generate (cyclomatic 30) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:839 — FileCoverCacheCoordinator.generate has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CursorStyle.asPointerStyle (cyclomatic 30) · ×1
  • CursorStyle.asPointerStyle (cyclomatic 30) ExcalidrawZ/Utils/CursorHoverView/CursorStyle.swift:99 — CursorStyle.asPointerStyle has cyclomatic complexity 30 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ExcalidrawHomeView.handleActiveGroupChanged (cyclomatic 30) · ×1
  • ExcalidrawHomeView.handleActiveGroupChanged (cyclomatic 30) ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:277 — ExcalidrawHomeView.handleActiveGroupChanged has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawLinearElement.== (cyclomatic 29) · ×1
  • ExcalidrawLinearElement.== (cyclomatic 29) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:321 — ExcalidrawLinearElement.== has cyclomatic complexity 29 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ExcalidrawFreeDrawElement.== (cyclomatic 27) · ×1
  • ExcalidrawFreeDrawElement.== (cyclomatic 27) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:180 — ExcalidrawFreeDrawElement.== has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ExcalidrawPdfElement.== (cyclomatic 27) · ×1
  • ExcalidrawPdfElement.== (cyclomatic 27) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:149 — ExcalidrawPdfElement.== has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · FileHomeItemTransitionModifier.body (cyclomatic 27) · ×1
  • FileHomeItemTransitionModifier.body (cyclomatic 27) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:143 — FileHomeItemTransitionModifier.body has cyclomatic complexity 27 (threshold 15). Of this number, 18 points are the body's own statements and 9 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileRowDragDropModifier.body (cyclomatic 26) · ×1
  • FileRowDragDropModifier.body (cyclomatic 26) ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:107 — FileRowDragDropModifier.body has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ScreenAnnotationView.body (cyclomatic 26) · ×1
  • ScreenAnnotationView.body (cyclomatic 26) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:42 — ScreenAnnotationView.body has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ExcalidrawImageElement.== (cyclomatic 26) · ×1
  • ExcalidrawImageElement.== (cyclomatic 26) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:161 — ExcalidrawImageElement.== has cyclomatic complexity 26 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · CloudStorageDocumentStore.replayPendingMetadataOperations (cyclomatic 26) · ×1
  • CloudStorageDocumentStore.replayPendingMetadataOperations (cyclomatic 26) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2303 — CloudStorageDocumentStore.replayPendingMetadataOperations has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileEnumerator.enumerateExpectedFiles (cyclomatic 26) · ×1
  • FileEnumerator.enumerateExpectedFiles (cyclomatic 26) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:249 — FileEnumerator.enumerateExpectedFiles has cyclomatic complexity 26 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · CollaborationEditor.body (cyclomatic 24) · ×1
  • CollaborationEditor.body (cyclomatic 24) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:49 — CollaborationEditor.body has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawGenericElement.== (cyclomatic 24) · ×1
  • ExcalidrawGenericElement.== (cyclomatic 24) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:131 — ExcalidrawGenericElement.== has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · CloudStorageDocumentStore.refreshedDeltaState (cyclomatic 24) · ×1
  • CloudStorageDocumentStore.refreshedDeltaState (cyclomatic 24) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2099 — CloudStorageDocumentStore.refreshedDeltaState has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawPresentationModel.load (cyclomatic 24) · ×1
  • ExcalidrawPresentationModel.load (cyclomatic 24) ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationModel.swift:98 — ExcalidrawPresentationModel.load has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ApplePencilToolbarModifier.onDragging (cyclomatic 24) · ×1
  • ApplePencilToolbarModifier.onDragging (cyclomatic 24) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/ApplePencilToolbar.swift:230 — ApplePencilToolbarModifier.onDragging has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawDrawElement.== (cyclomatic 23) · ×1
  • ExcalidrawDrawElement.== (cyclomatic 23) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:323 — ExcalidrawDrawElement.== has cyclomatic complexity 23 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · MediaCleanupCoordinator.scan (cyclomatic 23) · ×1
  • MediaCleanupCoordinator.scan (cyclomatic 23) ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift:108 — MediaCleanupCoordinator.scan has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · LocalFileRowView.body (cyclomatic 22) · ×1
  • LocalFileRowView.body (cyclomatic 22) ExcalidrawZ/Sidebar/Local/LocalFileRowView.swift:55 — LocalFileRowView.body has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SidebarRowDropable.handleDrop (cyclomatic 22) · ×1
  • SidebarRowDropable.handleDrop (cyclomatic 22) ExcalidrawZ/Sidebar/components/SidebarRowDropModifier.swift:14 — SidebarRowDropable.handleDrop has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ElementPropertiesPanel.options (cyclomatic 22) · ×1
  • ElementPropertiesPanel.options (cyclomatic 22) ExcalidrawZ/ExcalidrawView/components/ElementPropertiesPanel/ElementPropertiesPanel.swift:68 — ElementPropertiesPanel.options has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SyncCoordinator.performDiffScan (cyclomatic 22) · ×1
  • SyncCoordinator.performDiffScan (cyclomatic 22) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:407 — SyncCoordinator.performDiffScan has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ScreenAnnotationWebRuntime.userContentController (cyclomatic 21) · ×1
  • ScreenAnnotationWebRuntime.userContentController (cyclomatic 21) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWebRuntime.swift:250 — ScreenAnnotationWebRuntime.userContentController has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TemporaryFileMenuItems.moveFile (cyclomatic 21) · ×1
  • TemporaryFileMenuItems.moveFile (cyclomatic 21) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:207 — TemporaryFileMenuItems.moveFile has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DividerOverlayModifier.detectDivider (cyclomatic 21) · ×1
  • DividerOverlayModifier.detectDivider (cyclomatic 21) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitView.swift:248 — DividerOverlayModifier.detectDivider has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileICloudStatusIndicator.iCloudStatusContent (cyclomatic 21) · ×1
  • FileICloudStatusIndicator.iCloudStatusContent (cyclomatic 21) ExcalidrawZ/ContentView+/Detail/Components/FileICloudStatusIndicator.swift:46 — FileICloudStatusIndicator.iCloudStatusContent has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · HomeFolderItemView.body (cyclomatic 21) · ×1
  • HomeFolderItemView.body (cyclomatic 21) ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift:27 — HomeFolderItemView.body has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ApplePencilToolbarModifier.body (cyclomatic 21) · ×1
  • ApplePencilToolbarModifier.body (cyclomatic 21) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/ApplePencilToolbar.swift:77 — ApplePencilToolbarModifier.body has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ReadFileTool.baseInfo (cyclomatic 21) · ×1
  • ReadFileTool.baseInfo (cyclomatic 21) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:696 — ReadFileTool.baseInfo has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenURLSheetView.body (cyclomatic 20) · ×1
  • OpenURLSheetView.body (cyclomatic 20) ExcalidrawZ/ContentView+/Content+OpenFromURL.swift:452 — OpenURLSheetView.body has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · CursorStyle.asNSCursor (cyclomatic 20) · ×1
  • CursorStyle.asNSCursor (cyclomatic 20) ExcalidrawZ/Utils/CursorHoverView/CursorStyle.swift:151 — CursorStyle.asNSCursor has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · AdjustElementsTool.execute (cyclomatic 20) · ×1
  • AdjustElementsTool.execute (cyclomatic 20) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:59 — AdjustElementsTool.execute has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Utils.swift.backupFiles (cyclomatic 20) · ×1
  • Utils.swift.backupFiles (cyclomatic 20) ExcalidrawZ/Utils/Utils.swift:78 — Utils.swift.backupFiles has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · JoinRoomSheetView.parseLink (cyclomatic 19) · ×1
  • JoinRoomSheetView.parseLink (cyclomatic 19) ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:120 — JoinRoomSheetView.parseLink has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawEditor.persistCanvasUpdate (cyclomatic 19) · ×1
  • ExcalidrawEditor.persistCanvasUpdate (cyclomatic 19) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:1198 — ExcalidrawEditor.persistCanvasUpdate has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawDocumentSyncController.load (cyclomatic 19) · ×1
  • ExcalidrawDocumentSyncController.load (cyclomatic 19) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:216 — ExcalidrawDocumentSyncController.load has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileMenuItems.body (cyclomatic 19) · ×1
  • FileMenuItems.body (cyclomatic 19) ExcalidrawZ/Sidebar/components/FileContextMenu.swift:258 — FileMenuItems.body has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SyncCoordinator.processQueue (cyclomatic 19) · ×1
  • SyncCoordinator.processQueue (cyclomatic 19) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:215 — SyncCoordinator.processQueue has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PromptInputView.startSend (cyclomatic 19) · ×1
  • PromptInputView.startSend (cyclomatic 19) ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:171 — PromptInputView.startSend has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawEditor.loadExcalidrawFile (cyclomatic 18) · ×1
  • ExcalidrawEditor.loadExcalidrawFile (cyclomatic 18) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:695 — ExcalidrawEditor.loadExcalidrawFile has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ScreenAnnotationSaveConfiguration.init (cyclomatic 18) · ×1
  • ScreenAnnotationSaveConfiguration.init (cyclomatic 18) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift:225 — ScreenAnnotationSaveConfiguration.init has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ScreenAnnotationSession.prepareCanvas (cyclomatic 18) · ×1
  • ScreenAnnotationSession.prepareCanvas (cyclomatic 18) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:87 — ScreenAnnotationSession.prepareCanvas has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · CloudStorageDocumentStore.loadContent (cyclomatic 18) · ×1
  • CloudStorageDocumentStore.loadContent (cyclomatic 18) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1210 — CloudStorageDocumentStore.loadContent has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MigrationProgressSheet.body (cyclomatic 18) · ×1
  • MigrationProgressSheet.body (cyclomatic 18) ExcalidrawZ/Persistence/Migrations/MigrationSheetView.swift:58 — MigrationProgressSheet.body has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LocalFileRowMenuItems.body (cyclomatic 18) · ×1
  • LocalFileRowMenuItems.body (cyclomatic 18) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:240 — LocalFileRowMenuItems.body has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AIChatView.messageList (cyclomatic 18) · ×1
  • AIChatView.messageList (cyclomatic 18) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift:13 — AIChatView.messageList has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · overwrite_console.summarizeConsoleArg (cyclomatic 18) · ×1
  • overwrite_console.summarizeConsoleArg (cyclomatic 18) ExcalidrawZ/Resources/overwrite_console.js:13 — overwrite_console.summarizeConsoleArg has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AppDelegate.scheduleTerminationSheetIfNeeded (cyclomatic 17) · ×1
  • AppDelegate.scheduleTerminationSheetIfNeeded (cyclomatic 17) ExcalidrawZ/AppDelegate.swift:121 — AppDelegate.scheduleTerminationSheetIfNeeded has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ShareToolbarButton.performShareFile (cyclomatic 17) · ×1
  • ShareToolbarButton.performShareFile (cyclomatic 17) ExcalidrawZ/Share/ShareToolbarButton.swift:145 — ShareToolbarButton.performShareFile has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GroupsView.canDrop (cyclomatic 17) · ×1
  • GroupsView.canDrop (cyclomatic 17) ExcalidrawZ/Sidebar/GroupsView.swift:113 — GroupsView.canDrop has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · GroupsView.diclsureGroupView (cyclomatic 17) · ×1
  • GroupsView.diclsureGroupView (cyclomatic 17) ExcalidrawZ/Sidebar/GroupsView.swift:149 — GroupsView.diclsureGroupView has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ScreenAnnotationSession.syncSelectedElements (cyclomatic 17) · ×1
  • ScreenAnnotationSession.syncSelectedElements (cyclomatic 17) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:329 — ScreenAnnotationSession.syncSelectedElements has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: ScreenAnnotationSession.syncSelectedTool (cyclomatic 18) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · BackupsSettingsView.body (cyclomatic 17) · ×1
  • BackupsSettingsView.body (cyclomatic 17) ExcalidrawZ/Settings/BackupsSettings/BackupsSettingsView.swift:51 — BackupsSettingsView.body has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · MultiFontPickerView.body (cyclomatic 16) · ×1
  • MultiFontPickerView.body (cyclomatic 16) ExcalidrawZ/Settings/FontsSettingsView.swift:61 — MultiFontPickerView.body has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileState.applyCloudStorageIdentityChange (cyclomatic 16) · ×1
  • FileState.applyCloudStorageIdentityChange (cyclomatic 16) ExcalidrawZ/Store/FileState.swift:152 — FileState.applyCloudStorageIdentityChange has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileState.importFiles (cyclomatic 16) · ×1
  • FileState.importFiles (cyclomatic 16) ExcalidrawZ/Store/FileState.swift:1912 — FileState.importFiles has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FileStatusObserverModifier.handleICloudStatus (cyclomatic 16) · ×1
  • FileStatusObserverModifier.handleICloudStatus (cyclomatic 16) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+FileStatusObserver.swift:142 — FileStatusObserverModifier.handleICloudStatus has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawCanvasView.listenToLoadingState (cyclomatic 16) · ×1
  • ExcalidrawCanvasView.listenToLoadingState (cyclomatic 16) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift:283 — ExcalidrawCanvasView.listenToLoadingState has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExcalidrawDocumentSyncController.applyCanvasFileData (cyclomatic 16) · ×1
  • ExcalidrawDocumentSyncController.applyCanvasFileData (cyclomatic 16) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:425 — ExcalidrawDocumentSyncController.applyCanvasFileData has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ScreenAnnotationSession.clearCanvas (cyclomatic 16) · ×1
  • ScreenAnnotationSession.clearCanvas (cyclomatic 16) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:165 — ScreenAnnotationSession.clearCanvas has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: ScreenAnnotationSession.syncSelectedTool (cyclomatic 18) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · AISettingsView.activityBody (cyclomatic 16) · ×1
  • AISettingsView.activityBody (cyclomatic 16) ExcalidrawZ/Settings/AISettings/AISettingsView+Activity.swift:15 — AISettingsView.activityBody has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TemporaryFileMenuItems.moveLocalFile (cyclomatic 16) · ×1
  • TemporaryFileMenuItems.moveLocalFile (cyclomatic 16) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:303 — TemporaryFileMenuItems.moveLocalFile has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AIProposalArtifact.findArtifact (cyclomatic 16) · ×1
  • AIProposalArtifact.findArtifact (cyclomatic 16) ExcalidrawZ/SidebarTrailing/AIChat/AIProposalArtifact.swift:61 — AIProposalArtifact.findArtifact has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UserDrawingSettings.from (cyclomatic 16) · ×1
  • UserDrawingSettings.from (cyclomatic 16) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/UserDrawingSettings.swift:125 — UserDrawingSettings.from has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · UserDrawingSettings.filling (cyclomatic 16) · ×1
  • UserDrawingSettings.filling (cyclomatic 16) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/UserDrawingSettings.swift:253 — UserDrawingSettings.filling has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (UserDrawingSettings.merging) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · UserDrawingSettings.merging (cyclomatic 16) · ×1
  • UserDrawingSettings.merging (cyclomatic 16) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/UserDrawingSettings.swift:276 — UserDrawingSettings.merging has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (UserDrawingSettings.filling) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D1 · Cyclomatic Complexity · ElementProperties.changes (cyclomatic 16) · ×1
  • ElementProperties.changes (cyclomatic 16) ExcalidrawZ/ExcalidrawView/components/ElementPropertiesPanel/ElementProperties.swift:91 — ElementProperties.changes has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate (cyclomatic 16) · ×1
  • ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate (cyclomatic 16) ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:609 — ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · CollaborationHomeBackground.body (cyclomatic 16) · ×1
  • CollaborationHomeBackground.body (cyclomatic 16) ExcalidrawZ/ContentView+/Detail/Home/CollaborationHome/CollaborationHome.swift:204 — CollaborationHomeBackground.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AdjustElementsMiddleware.apply (cyclomatic 16) · ×1
  • AdjustElementsMiddleware.apply (cyclomatic 16) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:903 — AdjustElementsMiddleware.apply has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D2 · Cognitive Complexity · AdjustElementsMiddleware.patchElement (cognitive 89) · ×1
  • AdjustElementsMiddleware.patchElement (cognitive 89) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:25 — AdjustElementsMiddleware.patchElement has cognitive complexity 89 (threshold 15). Drivers by points: if/else 33 (77 pts), boolean chains 9, ternaries 1 (2 pts), match/switch 1 (nesting depth added 45). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FileRowDragDropModifier.sortFiles (cognitive 87) · ×1
  • FileRowDragDropModifier.sortFiles (cognitive 87) ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:268 — FileRowDragDropModifier.sortFiles has cognitive complexity 87 (threshold 15). Drivers by points: if/else 23 (63 pts), loops 4 (17 pts), boolean chains 4, match/switch 1 (2 pts), error handling 1 (nesting depth added 54). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawHomeView.handleActiveGroupChanged (cognitive 69) · ×1
  • ExcalidrawHomeView.handleActiveGroupChanged (cognitive 69) ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:277 — ExcalidrawHomeView.handleActiveGroupChanged has cognitive complexity 69 (threshold 15). Drivers by points: if/else 34 (65 pts), boolean chains 3, match/switch 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileState.performActiveFileChange (cognitive 68) · ×1
  • FileState.performActiveFileChange (cognitive 68) ExcalidrawZ/Store/FileState.swift:669 — FileState.performActiveFileChange has cognitive complexity 68 (threshold 15). Drivers by points: if/else 31 (51 pts), boolean chains 11, error handling 2 (5 pts), match/switch 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawRenderer.canvasView (cognitive 66) · ×1
  • ExcalidrawRenderer.canvasView (cognitive 66) ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:63 — ExcalidrawRenderer.canvasView has cognitive complexity 66 (threshold 15). Drivers by points: if/else 11 (32 pts), ternaries 5 (18 pts), loops 4 (10 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileCoverCacheCoordinator.generate (cognitive 53) · ×1
  • FileCoverCacheCoordinator.generate (cognitive 53) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:839 — FileCoverCacheCoordinator.generate has cognitive complexity 53 (threshold 15). Drivers by points: if/else 16 (41 pts), match/switch 2 (5 pts), boolean chains 4, error handling 2 (3 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.replayPendingMetadataOperations (cognitive 51) · ×1
  • CloudStorageDocumentStore.replayPendingMetadataOperations (cognitive 51) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2303 — CloudStorageDocumentStore.replayPendingMetadataOperations has cognitive complexity 51 (threshold 15). Drivers by points: if/else 10 (28 pts), error handling 3 (8 pts), ternaries 3 (7 pts), boolean chains 4, match/switch 1 (3 pts), loops 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ViewerLocalConnection.update (cognitive 50) · ×1
  • ViewerLocalConnection.update (cognitive 50) ExcalidrawZ/ExcalidrawView/Viewer/ViewerLocalConnection.swift:77 — ViewerLocalConnection.update has cognitive complexity 50 (threshold 15). Drivers by points: if/else 20 (30 pts), boolean chains 17, ternaries 2, error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TemporaryFileMenuItems.moveFile (cognitive 47) · ×1
  • TemporaryFileMenuItems.moveFile (cognitive 47) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:207 — TemporaryFileMenuItems.moveFile has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (37 pts), error handling 2 (5 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 25). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · FileHomeItemContentView.content (cognitive 46) · ×1
  • FileHomeItemContentView.content (cognitive 46) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:515 — FileHomeItemContentView.content has cognitive complexity 46 (threshold 15). Drivers by points: if/else 11 (16 pts), ternaries 9 (14 pts), boolean chains 8, match/switch 3 (8 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileEnumerator.enumerateExpectedFiles (cognitive 45) · ×1
  • FileEnumerator.enumerateExpectedFiles (cognitive 45) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:249 — FileEnumerator.enumerateExpectedFiles has cognitive complexity 45 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 6 (13 pts), boolean chains 8, error handling 5 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawHomeView.homeLayer (cognitive 43) · ×1
  • ExcalidrawHomeView.homeLayer (cognitive 43) ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:106 — ExcalidrawHomeView.homeLayer has cognitive complexity 43 (threshold 15). Drivers by points: ternaries 9 (18 pts), boolean chains 12, if/else 8 (12 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FileRowDragDropModifier.body (cognitive 40) · ×1
  • FileRowDragDropModifier.body (cognitive 40) ExcalidrawZ/Sidebar/FileRowView+DragMove.swift:107 — FileRowDragDropModifier.body has cognitive complexity 40 (threshold 15). Drivers by points: if/else 23 (35 pts), match/switch 2 (5 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawPresentationModel.load (cognitive 40) · ×1
  • ExcalidrawPresentationModel.load (cognitive 40) ExcalidrawZ/SidebarTrailing/Presentation/ExcalidrawPresentationModel.swift:98 — ExcalidrawPresentationModel.load has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 4, loops 2 (4 pts), ternaries 2 (4 pts), error handling 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileHomeItemTransitionModifier.body (cognitive 40) · ×1
  • FileHomeItemTransitionModifier.body (cognitive 40) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:143 — FileHomeItemTransitionModifier.body has cognitive complexity 40 (threshold 15). Drivers by points: if/else 18 (31 pts), boolean chains 8, match/switch 1 (nesting depth added 13). Of this number, 29 points are the body's own statements and 11 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ApplePencilToolbarModifier.body (cognitive 38) · ×1
  • ApplePencilToolbarModifier.body (cognitive 38) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/ApplePencilToolbar.swift:77 — ApplePencilToolbarModifier.body has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 6 (13 pts), boolean chains 5, error handling 2 (5 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HomeFolderItemView.body (cognitive 37) · ×1
  • HomeFolderItemView.body (cognitive 37) ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift:27 — HomeFolderItemView.body has cognitive complexity 37 (threshold 15). Drivers by points: ternaries 11 (21 pts), if/else 13 (15 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PromptInputView.startSend (cognitive 37) · ×1
  • PromptInputView.startSend (cognitive 37) ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+Send.swift:171 — PromptInputView.startSend has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (29 pts), error handling 2 (5 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ArchiveFilesModifier.swift.backupAllCloudFiles (cognitive 36) · ×1
  • ArchiveFilesModifier.swift.backupAllCloudFiles (cognitive 36) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:459 — ArchiveFilesModifier.swift.backupAllCloudFiles has cognitive complexity 36 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 4 (9 pts), error handling 2 (6 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CollaborationEditor.body (cognitive 35) · ×1
  • CollaborationEditor.body (cognitive 35) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:49 — CollaborationEditor.body has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 7, error handling 3 (6 pts), ternaries 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SyncCoordinator.processQueue (cognitive 35) · ×1
  • SyncCoordinator.processQueue (cognitive 35) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:215 — SyncCoordinator.processQueue has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (29 pts), error handling 1 (2 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SyncCoordinator.performDiffScan (cognitive 35) · ×1
  • SyncCoordinator.performDiffScan (cognitive 35) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:407 — SyncCoordinator.performDiffScan has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (29 pts), boolean chains 2, loops 2, match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JoinRoomSheetView.parseLink (cognitive 34) · ×1
  • JoinRoomSheetView.parseLink (cognitive 34) ExcalidrawZ/ExcalidrawView/Collaboration/JoinRoomSheetView.swift:120 — JoinRoomSheetView.parseLink has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 8 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Migration_ExtractMediaItems.migrate (cognitive 34) · ×1
  • Migration_ExtractMediaItems.migrate (cognitive 34) ExcalidrawZ/Persistence/Migrations/1_ExtractMediaItems.swift:48 — Migration_ExtractMediaItems.migrate has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (8 pts), error handling 2 (4 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DrawingSettingsPanel.body (cognitive 34) · ×1
  • DrawingSettingsPanel.body (cognitive 34) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsPanel.swift:18 — DrawingSettingsPanel.body has cognitive complexity 34 (threshold 15). Drivers by points: if/else 17 (24 pts), match/switch 9 (10 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileMenuItems.body (cognitive 33) · ×1
  • FileMenuItems.body (cognitive 33) ExcalidrawZ/Sidebar/components/FileContextMenu.swift:258 — FileMenuItems.body has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 7, error handling 1 (3 pts), loops 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawCore.userContentController (cognitive 33) · ×1
  • ExcalidrawCore.userContentController (cognitive 33) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:24 — ExcalidrawCore.userContentController has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (23 pts), match/switch 2 (5 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ArchiveFilesModifier.archiveAllCloudFilesWithErrorCollection (cognitive 32) · ×1
  • ArchiveFilesModifier.archiveAllCloudFilesWithErrorCollection (cognitive 32) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:107 — ArchiveFilesModifier.archiveAllCloudFilesWithErrorCollection has cognitive complexity 32 (threshold 15). Drivers by points: if/else 3 (16 pts), loops 3 (10 pts), error handling 2 (5 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawArrowElement.== (cognitive 32) · ×1
  • ExcalidrawArrowElement.== (cognitive 32) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:571 — ExcalidrawArrowElement.== has cognitive complexity 32 (threshold 15). Drivers by points: boolean chains 32. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · LocalFileRowView.body (cognitive 32) · ×1
  • LocalFileRowView.body (cognitive 32) ExcalidrawZ/Sidebar/Local/LocalFileRowView.swift:55 — LocalFileRowView.body has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 6, ternaries 4 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawTextElement.== (cognitive 31) · ×1
  • ExcalidrawTextElement.== (cognitive 31) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:141 — ExcalidrawTextElement.== has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 31. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · CloudStorageDocumentStore.refreshedDeltaState (cognitive 31) · ×1
  • CloudStorageDocumentStore.refreshedDeltaState (cognitive 31) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2099 — CloudStorageDocumentStore.refreshedDeltaState has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 7, loops 4 (5 pts), match/switch 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MigrationProgressSheet.body (cognitive 31) · ×1
  • MigrationProgressSheet.body (cognitive 31) ExcalidrawZ/Persistence/Migrations/MigrationSheetView.swift:58 — MigrationProgressSheet.body has cognitive complexity 31 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MediaCleanupCoordinator.scan (cognitive 31) · ×1
  • MediaCleanupCoordinator.scan (cognitive 31) ExcalidrawZ/Persistence/Repository/MediaCleanupCoordinator.swift:108 — MediaCleanupCoordinator.scan has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 5 (7 pts), boolean chains 5, error handling 2 (4 pts), match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileState.importFiles (cognitive 30) · ×1
  • FileState.importFiles (cognitive 30) ExcalidrawZ/Store/FileState.swift:1912 — FileState.importFiles has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (23 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawDocumentSyncController.load (cognitive 30) · ×1
  • ExcalidrawDocumentSyncController.load (cognitive 30) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:216 — ExcalidrawDocumentSyncController.load has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 5, error handling 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScreenAnnotationView.body (cognitive 30) · ×1
  • ScreenAnnotationView.body (cognitive 30) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationView.swift:42 — ScreenAnnotationView.body has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (16 pts), error handling 3 (5 pts), boolean chains 4, ternaries 2 (4 pts), match/switch 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · ShareToolbarButton.performShareFile (cognitive 29) · ×1
  • ShareToolbarButton.performShareFile (cognitive 29) ExcalidrawZ/Share/ShareToolbarButton.swift:145 — ShareToolbarButton.performShareFile has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 1 (3 pts), boolean chains 1, error handling 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.performRefresh (cognitive 29) · ×1
  • CloudStorageDocumentStore.performRefresh (cognitive 29) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:549 — CloudStorageDocumentStore.performRefresh has cognitive complexity 29 (threshold 15). Drivers by points: error handling 6 (14 pts), if/else 8 (14 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileRepository.delete (cognitive 29) · ×1
  • FileRepository.delete (cognitive 29) ExcalidrawZ/Persistence/Repository/FileRepository.swift:581 — FileRepository.delete has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExportButtonStyle.makeBody (cognitive 29) · ×1
  • ExportButtonStyle.makeBody (cognitive 29) ExcalidrawZ/Share/components/ExportButtonStyle.swift:19 — ExportButtonStyle.makeBody has cognitive complexity 29 (threshold 15). Drivers by points: ternaries 8 (20 pts), if/else 6 (9 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SidebarRowDropable.handleDrop (cognitive 29) · ×1
  • SidebarRowDropable.handleDrop (cognitive 29) ExcalidrawZ/Sidebar/components/SidebarRowDropModifier.swift:14 — SidebarRowDropable.handleDrop has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 11, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawLibraryImportSheetView.body (cognitive 29) · ×1
  • ExcalidrawLibraryImportSheetView.body (cognitive 29) ExcalidrawZ/SidebarTrailing/Library/LibraryImportSheetView.swift:129 — ExcalidrawLibraryImportSheetView.body has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (14 pts), loops 6 (14 pts), ternaries 1 (nesting depth added 9). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · PlanCard.body (cognitive 29) · ×1
  • PlanCard.body (cognitive 29) ExcalidrawZ/Subscription/components/RegularPlansView.swift:136 — PlanCard.body has cognitive complexity 29 (threshold 15). Drivers by points: ternaries 9 (20 pts), if/else 7 (9 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ArchiveFilesModifier.swift.archiveAllCloudFiles (cognitive 29) · ×1
  • ArchiveFilesModifier.swift.archiveAllCloudFiles (cognitive 29) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:306 — ArchiveFilesModifier.swift.archiveAllCloudFiles has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 4 (9 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawEditor.persistCanvasUpdate (cognitive 28) · ×1
  • ExcalidrawEditor.persistCanvasUpdate (cognitive 28) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:1198 — ExcalidrawEditor.persistCanvasUpdate has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (19 pts), error handling 3 (6 pts), boolean chains 2, match/switch 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawLinearElement.== (cognitive 28) · ×1
  • ExcalidrawLinearElement.== (cognitive 28) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:321 — ExcalidrawLinearElement.== has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 28. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · TemporaryGroupMenuItems.moveFiles (cognitive 28) · ×1
  • TemporaryGroupMenuItems.moveFiles (cognitive 28) ExcalidrawZ/Sidebar/Temporary/TemporaryGroupContextMenu.swift:105 — TemporaryGroupMenuItems.moveFiles has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (18 pts), error handling 2 (5 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AssistantRoundTableRows.items (cognitive 28) · ×1
  • AssistantRoundTableRows.items (cognitive 28) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:213 — AssistantRoundTableRows.items has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (14 pts), ternaries 2 (8 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Utils.swift.backupFiles (cognitive 28) · ×1
  • Utils.swift.backupFiles (cognitive 28) ExcalidrawZ/Utils/Utils.swift:78 — Utils.swift.backupFiles has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (18 pts), error handling 4 (5 pts), boolean chains 3, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Migration_MoveContentToICloudDrive.migrateFiles (cognitive 27) · ×1
  • Migration_MoveContentToICloudDrive.migrateFiles (cognitive 27) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:104 — Migration_MoveContentToICloudDrive.migrateFiles has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), error handling 2 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (Migration_MoveContentToICloudDrive.migrateCollaborationFiles, Migration_MoveContentToICloudDrive.migrateCheckpoints) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · Migration_MoveContentToICloudDrive.migrateCollaborationFiles (cognitive 27) · ×1
  • Migration_MoveContentToICloudDrive.migrateCollaborationFiles (cognitive 27) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:220 — Migration_MoveContentToICloudDrive.migrateCollaborationFiles has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), error handling 2 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (Migration_MoveContentToICloudDrive.migrateFiles, Migration_MoveContentToICloudDrive.migrateCheckpoints) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · Migration_MoveContentToICloudDrive.migrateCheckpoints (cognitive 27) · ×1
  • Migration_MoveContentToICloudDrive.migrateCheckpoints (cognitive 27) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:438 — Migration_MoveContentToICloudDrive.migrateCheckpoints has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), error handling 2 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (Migration_MoveContentToICloudDrive.migrateFiles, Migration_MoveContentToICloudDrive.migrateCollaborationFiles) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ApplePencilToolbarModifier.onDragging (cognitive 27) · ×1
  • ApplePencilToolbarModifier.onDragging (cognitive 27) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/ApplePencilToolbar.swift:230 — ApplePencilToolbarModifier.onDragging has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 10, match/switch 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WebDAVClient.resolveEndpoint (cognitive 27) · ×1
  • WebDAVClient.resolveEndpoint (cognitive 27) ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift:46 — WebDAVClient.resolveEndpoint has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 5 (6 pts), error handling 2 (4 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultiFontPickerView.body (cognitive 26) · ×1
  • MultiFontPickerView.body (cognitive 26) ExcalidrawZ/Settings/FontsSettingsView.swift:61 — MultiFontPickerView.body has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (16 pts), ternaries 3 (7 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawEditor.loadExcalidrawFile (cognitive 26) · ×1
  • ExcalidrawEditor.loadExcalidrawFile (cognitive 26) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:695 — ExcalidrawEditor.loadExcalidrawFile has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (19 pts), error handling 3, match/switch 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawFreeDrawElement.== (cognitive 26) · ×1
  • ExcalidrawFreeDrawElement.== (cognitive 26) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:180 — ExcalidrawFreeDrawElement.== has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 26. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · ExcalidrawArrowElement.encode (cognitive 26) · ×1
  • ExcalidrawArrowElement.encode (cognitive 26) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:477 — ExcalidrawArrowElement.encode has cognitive complexity 26 (threshold 15). Drivers by points: if/else 26. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ExcalidrawPdfElement.== (cognitive 26) · ×1
  • ExcalidrawPdfElement.== (cognitive 26) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:149 — ExcalidrawPdfElement.== has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 26. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · LocalFileRowMenuItems.duplicateFile (cognitive 26) · ×1
  • LocalFileRowMenuItems.duplicateFile (cognitive 26) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:418 — LocalFileRowMenuItems.duplicateFile has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 5, loops 2 (5 pts), error handling 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CompactPlansView.planButtons (cognitive 26) · ×1
  • CompactPlansView.planButtons (cognitive 26) ExcalidrawZ/Subscription/components/CompactPlansView.swift:44 — CompactPlansView.planButtons has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (14 pts), if/else 8 (11 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DividerOverlayModifier.detectDivider (cognitive 26) · ×1
  • DividerOverlayModifier.detectDivider (cognitive 26) ExcalidrawZ/components/FlexibleSplitView/FlexibleSplitView.swift:248 — DividerOverlayModifier.detectDivider has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 4, ternaries 2 (4 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ExcalidrawImageElement.== (cognitive 25) · ×1
  • ExcalidrawImageElement.== (cognitive 25) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:161 — ExcalidrawImageElement.== has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 25. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · LocalFileRowMenuItems.body (cognitive 25) · ×1
  • LocalFileRowMenuItems.body (cognitive 25) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:240 — LocalFileRowMenuItems.body has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 5 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TemporaryFileMenuItems.moveLocalFile (cognitive 25) · ×1
  • TemporaryFileMenuItems.moveLocalFile (cognitive 25) ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:303 — TemporaryFileMenuItems.moveLocalFile has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 5, error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExportImageView.actionItems (cognitive 24) · ×1
  • ExportImageView.actionItems (cognitive 24) ExcalidrawZ/Share/ExportImageView.swift:600 — ExportImageView.actionItems has cognitive complexity 24 (threshold 15). Drivers by points: if/else 16 (21 pts), match/switch 3 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ScreenAnnotationSaveConfiguration.init (cognitive 24) · ×1
  • ScreenAnnotationSaveConfiguration.init (cognitive 24) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSaveDestination.swift:225 — ScreenAnnotationSaveConfiguration.init has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileRepository.resetUnlockedFilesRecoveryKey (cognitive 24) · ×1
  • FileRepository.resetUnlockedFilesRecoveryKey (cognitive 24) ExcalidrawZ/Persistence/Repository/FileRepository+LockedContent.swift:256 — FileRepository.resetUnlockedFilesRecoveryKey has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 2, error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AISettingsView.activityBody (cognitive 24) · ×1
  • AISettingsView.activityBody (cognitive 24) ExcalidrawZ/Settings/AISettings/AISettingsView+Activity.swift:15 — AISettingsView.activityBody has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileState.endAIChatSession (cognitive 23) · ×1
  • FileState.endAIChatSession (cognitive 23) ExcalidrawZ/Store/FileState+AIChatSession.swift:108 — FileState.endAIChatSession has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (18 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudKitSyncModifier.startCloudKitEventListener (cognitive 23) · ×1
  • CloudKitSyncModifier.startCloudKitEventListener (cognitive 23) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+CloudKitSync.swift:30 — CloudKitSyncModifier.startCloudKitEventListener has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 2 (6 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawToolbar.compactContent (cognitive 23) · ×1
  • ExcalidrawToolbar.compactContent (cognitive 23) ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:396 — ExcalidrawToolbar.compactContent has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawGenericElement.== (cognitive 23) · ×1
  • ExcalidrawGenericElement.== (cognitive 23) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:131 — ExcalidrawGenericElement.== has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 23. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · AIProposalArtifact.findArtifact (cognitive 23) · ×1
  • AIProposalArtifact.findArtifact (cognitive 23) ExcalidrawZ/SidebarTrailing/AIChat/AIProposalArtifact.swift:61 — AIProposalArtifact.findArtifact has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 6, loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawDocumentSyncController.applyCanvasFileData (cognitive 22) · ×1
  • ExcalidrawDocumentSyncController.applyCanvasFileData (cognitive 22) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawDocumentSyncController.swift:425 — ExcalidrawDocumentSyncController.applyCanvasFileData has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 5, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CompactExcalidrawBottomToolbarContent.body (cognitive 22) · ×1
  • CompactExcalidrawBottomToolbarContent.body (cognitive 22) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:31 — CompactExcalidrawBottomToolbarContent.body has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawDrawElement.== (cognitive 22) · ×1
  • ExcalidrawDrawElement.== (cognitive 22) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:323 — ExcalidrawDrawElement.== has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 22. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · CloudStorageDocumentStore.remoteContentCandidate (cognitive 22) · ×1
  • CloudStorageDocumentStore.remoteContentCandidate (cognitive 22) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:901 — CloudStorageDocumentStore.remoteContentCandidate has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), error handling 2, boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhatsNewView.allFeaturesList (cognitive 22) · ×1
  • WhatsNewView.allFeaturesList (cognitive 22) ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:43 — WhatsNewView.allFeaturesList has cognitive complexity 22 (threshold 15). Drivers by points: if/else 21 (22 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · FileHomeItemSelectModifier.performFileSelect (cognitive 22) · ×1
  • FileHomeItemSelectModifier.performFileSelect (cognitive 22) ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:182 — FileHomeItemSelectModifier.performFileSelect has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (FileHomeItemSelectModifier.performLocalFileSelect, FileHomeItemSelectModifier.performTemporaryFileSelect) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · FileHomeItemSelectModifier.performLocalFileSelect (cognitive 22) · ×1
  • FileHomeItemSelectModifier.performLocalFileSelect (cognitive 22) ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:218 — FileHomeItemSelectModifier.performLocalFileSelect has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (FileHomeItemSelectModifier.performFileSelect, FileHomeItemSelectModifier.performTemporaryFileSelect) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · FileHomeItemSelectModifier.performTemporaryFileSelect (cognitive 22) · ×1
  • FileHomeItemSelectModifier.performTemporaryFileSelect (cognitive 22) ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:254 — FileHomeItemSelectModifier.performTemporaryFileSelect has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (FileHomeItemSelectModifier.performFileSelect, FileHomeItemSelectModifier.performLocalFileSelect) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · ExcalidrawCanvasView.listenToLoadingState (cognitive 21) · ×1
  • ExcalidrawCanvasView.listenToLoadingState (cognitive 21) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift:283 — ExcalidrawCanvasView.listenToLoadingState has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (8 pts), ternaries 1 (3 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScreenAnnotationSelectionProperties.properties (cognitive 21) · ×1
  • ScreenAnnotationSelectionProperties.properties (cognitive 21) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSelectionProperties.swift:51 — ScreenAnnotationSelectionProperties.properties has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 3 (7 pts), boolean chains 4 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.processContentSynchronizationQueue (cognitive 21) · ×1
  • CloudStorageDocumentStore.processContentSynchronizationQueue (cognitive 21) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:747 — CloudStorageDocumentStore.processContentSynchronizationQueue has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 2 (4 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.loadContent (cognitive 21) · ×1
  • CloudStorageDocumentStore.loadContent (cognitive 21) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:1210 — CloudStorageDocumentStore.loadContent has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupRepository.delete (cognitive 21) · ×1
  • GroupRepository.delete (cognitive 21) ExcalidrawZ/Persistence/Repository/GroupRepository.swift:77 — GroupRepository.delete has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawZSidebarRowModifier.rowBackground (cognitive 21) · ×1
  • ExcalidrawZSidebarRowModifier.rowBackground (cognitive 21) ExcalidrawZ/Sidebar/components/SidebarRowModifier.swift:69 — ExcalidrawZSidebarRowModifier.rowBackground has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 7 (17 pts), if/else 3 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CursorStyle.asPointerStyle (cognitive 21) · ×1
  • CursorStyle.asPointerStyle (cognitive 21) ExcalidrawZ/Utils/CursorHoverView/CursorStyle.swift:99 — CursorStyle.asPointerStyle has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 2 (3 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FileHomeItemSelectModifier.performCloudStorageFileSelect (cognitive 21) · ×1
  • FileHomeItemSelectModifier.performCloudStorageFileSelect (cognitive 21) ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift:290 — FileHomeItemSelectModifier.performCloudStorageFileSelect has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CompactContentMoreMenu.body (cognitive 21) · ×1
  • CompactContentMoreMenu.body (cognitive 21) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:583 — CompactContentMoreMenu.body has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 1 (4 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AdjustElementsTool.execute (cognitive 21) · ×1
  • AdjustElementsTool.execute (cognitive 21) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool.swift:59 — AdjustElementsTool.execute has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 7, error handling 5, boolean chains 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ReadFileTool.baseInfo (cognitive 21) · ×1
  • ReadFileTool.baseInfo (cognitive 21) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:696 — ReadFileTool.baseInfo has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 10 (20 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AssistantRoundView.renderItems (cognitive 21) · ×1
  • AssistantRoundView.renderItems (cognitive 21) ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift:431 — AssistantRoundView.renderItems has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Utils.swift.rewrapEncryptedBackupFilesRecoveryKey (cognitive 21) · ×1
  • Utils.swift.rewrapEncryptedBackupFilesRecoveryKey (cognitive 21) ExcalidrawZ/Utils/Utils.swift:504 — Utils.swift.rewrapEncryptedBackupFilesRecoveryKey has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), error handling 2 (4 pts), loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileRowView.content (cognitive 20) · ×1
  • FileRowView.content (cognitive 20) ExcalidrawZ/Sidebar/FileRowView.swift:71 — FileRowView.content has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NewFileButton.createNewFileFromClipboard (cognitive 20) · ×1
  • NewFileButton.createNewFileFromClipboard (cognitive 20) ExcalidrawZ/components/NewFileButton.swift:258 — NewFileButton.createNewFileFromClipboard has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileStatusObserverModifier.handleICloudStatus (cognitive 20) · ×1
  • FileStatusObserverModifier.handleICloudStatus (cognitive 20) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor+FileStatusObserver.swift:142 — FileStatusObserverModifier.handleICloudStatus has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (18 pts), error handling 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawEditor.pullUpdatingFromCloud (cognitive 20) · ×1
  • ExcalidrawEditor.pullUpdatingFromCloud (cognitive 20) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:1097 — ExcalidrawEditor.pullUpdatingFromCloud has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 3, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScreenAnnotationSession.prepareCanvas (cognitive 20) · ×1
  • ScreenAnnotationSession.prepareCanvas (cognitive 20) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:87 — ScreenAnnotationSession.prepareCanvas has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, if/else 6 (9 pts), error handling 1 (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · ScreenAnnotationWebRuntime.userContentController (cognitive 20) · ×1
  • ScreenAnnotationWebRuntime.userContentController (cognitive 20) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWebRuntime.swift:250 — ScreenAnnotationWebRuntime.userContentController has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 2, ternaries 1 (2 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawEditorToolbarModifier.body (cognitive 20) · ×1
  • ExcalidrawEditorToolbarModifier.body (cognitive 20) ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawEditorToolbarModifier.swift:73 — ExcalidrawEditorToolbarModifier.body has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (13 pts), ternaries 4 (6 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · MigrationManager.runPendingMigrations (cognitive 20) · ×1
  • MigrationManager.runPendingMigrations (cognitive 20) ExcalidrawZ/Persistence/Migrations/MigrationManager.swift:99 — MigrationManager.runPendingMigrations has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 pts), error handling 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CollaborationFileRepository.delete (cognitive 20) · ×1
  • CollaborationFileRepository.delete (cognitive 20) ExcalidrawZ/Persistence/Repository/CollaborationFileRepository.swift:425 — CollaborationFileRepository.delete has cognitive complexity 20 (threshold 15). Drivers by points: error handling 4 (8 pts), if/else 7 (8 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileMenuItems.moveFile (cognitive 20) · ×1
  • FileMenuItems.moveFile (cognitive 20) ExcalidrawZ/Sidebar/components/FileContextMenu.swift:436 — FileMenuItems.moveFile has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LibraryView.moveSelectionsToLibrary (cognitive 20) · ×1
  • LibraryView.moveSelectionsToLibrary (cognitive 20) ExcalidrawZ/SidebarTrailing/Library/LibraryView.swift:596 — LibraryView.moveSelectionsToLibrary has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (4 pts), error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WhatsNewView.body (cognitive 20) · ×1
  • WhatsNewView.body (cognitive 20) ExcalidrawZ/components/WhatsNew/WhatsNewSheetView.swift:177 — WhatsNewView.body has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPJSONValue.validateStrictJSONSyntax (cognitive 20) · ×1
  • MCPJSONValue.validateStrictJSONSyntax (cognitive 20) ExcalidrawZ/Utils/MCP/Runtime/MCPJSONValue.swift:145 — MCPJSONValue.validateStrictJSONSyntax has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NewFileButton.createNewFile (cognitive 19) · ×1
  • NewFileButton.createNewFile (cognitive 19) ExcalidrawZ/components/NewFileButton.swift:152 — NewFileButton.createNewFile has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawEditor.scheduleCloudStorageRefresh (cognitive 19) · ×1
  • ExcalidrawEditor.scheduleCloudStorageRefresh (cognitive 19) ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditor.swift:840 — ExcalidrawEditor.scheduleCloudStorageRefresh has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 3 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawPNGDecoder.decode (cognitive 19) · ×1
  • ExcalidrawPNGDecoder.decode (cognitive 19) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawPNGDecoder.swift:27 — ExcalidrawPNGDecoder.decode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Migration_MoveContentToICloudDrive.migrateMediaItems (cognitive 19) · ×1
  • Migration_MoveContentToICloudDrive.migrateMediaItems (cognitive 19) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:336 — Migration_MoveContentToICloudDrive.migrateMediaItems has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 1 (3 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFolderRepository.importToGroup (cognitive 19) · ×1
  • LocalFolderRepository.importToGroup (cognitive 19) ExcalidrawZ/Persistence/Repository/LocalFolderRepository.swift:24 — LocalFolderRepository.importToGroup has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, loops 2, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackupsSettingsView.body (cognitive 19) · ×1
  • BackupsSettingsView.body (cognitive 19) ExcalidrawZ/Settings/BackupsSettings/BackupsSettingsView.swift:51 — BackupsSettingsView.body has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 1, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · UserDrawingSettings.from (cognitive 19) · ×1
  • UserDrawingSettings.from (cognitive 19) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/UserDrawingSettings.swift:125 — UserDrawingSettings.from has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · LibraryItemCanvasElementPreprocessor.remapIDs (cognitive 19) · ×1
  • LibraryItemCanvasElementPreprocessor.remapIDs (cognitive 19) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:332 — LibraryItemCanvasElementPreprocessor.remapIDs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 5, loops 3 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate (cognitive 19) · ×1
  • ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate (cognitive 19) ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPOptimizedTools.swift:609 — ExcalidrawMCPOptimizedToolHandler.canvasPreferencesUpdate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (19 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · MathInputSheetView.generateLatexWithAI (cognitive 19) · ×1
  • MathInputSheetView.generateLatexWithAI (cognitive 19) ExcalidrawZ/ExcalidrawView/Toolbar/components/MathInput/MathInputSheetView+Actions.swift:216 — MathInputSheetView.generateLatexWithAI has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 3, error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AIProposalElementIDRegenerator.remapIDs (cognitive 19) · ×1
  • AIProposalElementIDRegenerator.remapIDs (cognitive 19) ExcalidrawZ/SidebarTrailing/AIChat/components/ToolCards/AIProposalToolResultCard.swift:324 — AIProposalElementIDRegenerator.remapIDs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 5, loops 3 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JSONValue.firstString (cognitive 19) · ×1
  • JSONValue.firstString (cognitive 19) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+MathImageTypes.swift:76 — JSONValue.firstString has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · OpenFromURLModifier.onOpenLocalFile (cognitive 18) · ×1
  • OpenFromURLModifier.onOpenLocalFile (cognitive 18) ExcalidrawZ/ContentView+/Content+OpenFromURL.swift:189 — OpenFromURLModifier.onOpenLocalFile has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3 (5 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileState.applyCloudStorageIdentityChange (cognitive 18) · ×1
  • FileState.applyCloudStorageIdentityChange (cognitive 18) ExcalidrawZ/Store/FileState.swift:152 — FileState.applyCloudStorageIdentityChange has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 8, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NewFileButton.createFile (cognitive 18) · ×1
  • NewFileButton.createFile (cognitive 18) ExcalidrawZ/components/NewFileButton.swift:211 — NewFileButton.createFile has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 2, ternaries 1 (2 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScreenAnnotationSession.clearCanvas (cognitive 18) · ×1
  • ScreenAnnotationSession.clearCanvas (cognitive 18) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:165 — ScreenAnnotationSession.clearCanvas has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 8, error handling 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScreenAnnotationSession.syncSelectedElements (cognitive 18) · ×1
  • ScreenAnnotationSession.syncSelectedElements (cognitive 18) ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationSession.swift:329 — ScreenAnnotationSession.syncSelectedElements has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 7, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · ExcalidrawSVGDecoder.decode (cognitive 18) · ×1
  • ExcalidrawSVGDecoder.decode (cognitive 18) ExcalidrawZ/Extensions/Excalidraw+Image/ExcalidrawSVGDecoder.swift:12 — ExcalidrawSVGDecoder.decode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, ternaries 1 (2 pts), error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawLinearElement.encode (cognitive 18) · ×1
  • ExcalidrawLinearElement.encode (cognitive 18) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:247 — ExcalidrawLinearElement.encode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 18. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · AIChatAttachmentRepository.garbageCollect (cognitive 18) · ×1
  • AIChatAttachmentRepository.garbageCollect (cognitive 18) ExcalidrawZ/Persistence/Repository/AIChatAttachmentRepository.swift:249 — AIChatAttachmentRepository.garbageCollect has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AISettingsView.settingsTabHeader (cognitive 18) · ×1
  • AISettingsView.settingsTabHeader (cognitive 18) ExcalidrawZ/Settings/AISettings/AISettingsView+Tabs.swift:11 — AISettingsView.settingsTabHeader has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (18 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackupsSettingsView.unlockBackupPreviewWithSystemAuthentication (cognitive 18) · ×1
  • BackupsSettingsView.unlockBackupPreviewWithSystemAuthentication (cognitive 18) ExcalidrawZ/Settings/BackupsSettings/BackupsSettingsView.swift:252 — BackupsSettingsView.unlockBackupPreviewWithSystemAuthentication has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupMenuItems.body (cognitive 18) · ×1
  • GroupMenuItems.body (cognitive 18) ExcalidrawZ/Sidebar/components/GroupContextMenu.swift:386 — GroupMenuItems.body has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SegmentedPicker.body (cognitive 18) · ×1
  • SegmentedPicker.body (cognitive 18) ExcalidrawZ/components/SegmentedPicker/SegmentedPicker.swift:45 — SegmentedPicker.body has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (5 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawCore.waitUntilReadyForFileLoad (cognitive 18) · ×1
  • ExcalidrawCore.waitUntilReadyForFileLoad (cognitive 18) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift:274 — ExcalidrawCore.waitUntilReadyForFileLoad has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 6, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileEnumerator.enumerateICloudFiles (cognitive 18) · ×1
  • FileEnumerator.enumerateICloudFiles (cognitive 18) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:97 — FileEnumerator.enumerateICloudFiles has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 4 (8 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ImageURLResourceLoader.load (cognitive 18) · ×1
  • ImageURLResourceLoader.load (cognitive 18) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddOperation.swift:462 — ImageURLResourceLoader.load has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3, loops 1 (2 pts), ternaries 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · File.loadContent (cognitive 18) · ×1
  • File.loadContent (cognitive 18) ExcalidrawZ/Persistence/iCloudDrive/File+iCloudDrive.swift:18 — File.loadContent has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · overwrite_console.summarizeConsoleArg (cognitive 18) · ×1
  • overwrite_console.summarizeConsoleArg (cognitive 18) ExcalidrawZ/Resources/overwrite_console.js:13 — overwrite_console.summarizeConsoleArg has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8, boolean chains 4, ternaries 2 (4 pts), error handling 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · ExportImageView.exportImageData (cognitive 17) · ×1
  • ExportImageView.exportImageData (cognitive 17) ExcalidrawZ/Share/ExportImageView.swift:714 — ExportImageView.exportImageData has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 3 (4 pts), boolean chains 1, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupRowDropModifier.handleDropFile (cognitive 17) · ×1
  • GroupRowDropModifier.handleDropFile (cognitive 17) ExcalidrawZ/Sidebar/GroupRowView+DragMove.swift:190 — GroupRowDropModifier.handleDropFile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupsView.diclsureGroupView (cognitive 17) · ×1
  • GroupsView.diclsureGroupView (cognitive 17) ExcalidrawZ/Sidebar/GroupsView.swift:149 — GroupsView.diclsureGroupView has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (7 pts), ternaries 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · FileState.restoreActiveCanvas (cognitive 17) · ×1
  • FileState.restoreActiveCanvas (cognitive 17) ExcalidrawZ/Store/FileState+History.swift:16 — FileState.restoreActiveCanvas has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 3 (6 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CompactAIChatReplyTicker.handleReplyTickerVisibility (cognitive 17) · ×1
  • CompactAIChatReplyTicker.handleReplyTickerVisibility (cognitive 17) ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift:223 — CompactAIChatReplyTicker.handleReplyTickerVisibility has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileCoverCacheCoordinator.restorePersistedPreview (cognitive 17) · ×1
  • FileCoverCacheCoordinator.restorePersistedPreview (cognitive 17) ExcalidrawZ/ExcalidrawView/components/FileCoverCacheCoordinator.swift:285 — FileCoverCacheCoordinator.restorePersistedPreview has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 5, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ExcalidrawFile.init (cognitive 17) · ×1
  • ExcalidrawFile.init (cognitive 17) ExcalidrawZ/Models/ExcalidrawFile/ExcalidrawFile.swift:160 — ExcalidrawFile.init has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), match/switch 2, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CloudStorageDocumentStore.folderSyncStates (cognitive 17) · ×1
  • CloudStorageDocumentStore.folderSyncStates (cognitive 17) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:390 — CloudStorageDocumentStore.folderSyncStates has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 4, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CoreDataMigrationModifier.startContinuousCloudKitMonitoring (cognitive 17) · ×1
  • CoreDataMigrationModifier.startContinuousCloudKitMonitoring (cognitive 17) ExcalidrawZ/Persistence/Migrations/MigrationState.swift:202 — CoreDataMigrationModifier.startContinuousCloudKitMonitoring has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFilesProvider.getFolderContents (cognitive 17) · ×1
  • LocalFilesProvider.getFolderContents (cognitive 17) ExcalidrawZ/Sidebar/Local/LocalFilesProvider.swift:160 — LocalFilesProvider.getFolderContents has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 5, ternaries 1 (3 pts), error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFolderMenuItems.body (cognitive 17) · ×1
  • LocalFolderMenuItems.body (cognitive 17) ExcalidrawZ/Sidebar/Local/LocalFolderContextMenu.swift:243 — LocalFolderMenuItems.body has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MissingFileMenuProvider.tryToRecoverFiles (cognitive 17) · ×1
  • MissingFileMenuProvider.tryToRecoverFiles (cognitive 17) ExcalidrawZ/Sidebar/components/MissingFileMenu.swift:107 — MissingFileMenuProvider.tryToRecoverFiles has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LibraryView.bottomBar (cognitive 17) · ×1
  • LibraryView.bottomBar (cognitive 17) ExcalidrawZ/SidebarTrailing/Library/LibraryView.swift:442 — LibraryView.bottomBar has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawCore.configWebView (cognitive 17) · ×1
  • ExcalidrawCore.configWebView (cognitive 17) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore.swift:104 — ExcalidrawCore.configWebView has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 1, error handling 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColorButtonGroup.body (cognitive 17) · ×1
  • ColorButtonGroup.body (cognitive 17) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ColorPicker/ColorButtonGroup.swift:36 — ColorButtonGroup.body has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, ternaries 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AIChatView.messageList (cognitive 17) · ×1
  • AIChatView.messageList (cognitive 17) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Messages.swift:13 — AIChatView.messageList has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7, boolean chains 5, ternaries 5. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · AppDelegate.scheduleTerminationSheetIfNeeded (cognitive 16) · ×1
  • AppDelegate.scheduleTerminationSheetIfNeeded (cognitive 16) ExcalidrawZ/AppDelegate.swift:121 — AppDelegate.scheduleTerminationSheetIfNeeded has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, if/else 4. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · SerachContent.body (cognitive 16) · ×1
  • SerachContent.body (cognitive 16) ExcalidrawZ/ContentView+/Content+Searchable.swift:205 — SerachContent.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (16 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GroupsView.canDrop (cognitive 16) · ×1
  • GroupsView.canDrop (cognitive 16) ExcalidrawZ/Sidebar/GroupsView.swift:113 — GroupsView.canDrop has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 10, if/else 6. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · FileState.recoverFile (cognitive 16) · ×1
  • FileState.recoverFile (cognitive 16) ExcalidrawZ/Store/FileState.swift:2153 — FileState.recoverFile has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (16 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Store.loadCustomerProductStatus (cognitive 16) · ×1
  • Store.loadCustomerProductStatus (cognitive 16) ExcalidrawZ/Subscription/Store_AppStore.swift:317 — Store.loadCustomerProductStatus has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 1 (3 pts), error handling 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NewGroupButton.content (cognitive 16) · ×1
  • NewGroupButton.content (cognitive 16) ExcalidrawZ/components/NewGroupButton.swift:112 — NewGroupButton.content has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), ternaries 1 (3 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ExcalidrawCanvasView.listenToDocumentLoadEvents (cognitive 16) · ×1
  • ExcalidrawCanvasView.listenToDocumentLoadEvents (cognitive 16) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift:322 — ExcalidrawCanvasView.listenToDocumentLoadEvents has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), match/switch 2 (5 pts), ternaries 1 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.deleteItem (cognitive 16) · ×1
  • CloudStorageDocumentStore.deleteItem (cognitive 16) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2000 — CloudStorageDocumentStore.deleteItem has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6, boolean chains 5, error handling 1 (2 pts), loops 1 (2 pts), ternaries 1 (nesting depth added 2). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CloudStorageDocumentStore.enqueueMove (cognitive 16) · ×1
  • CloudStorageDocumentStore.enqueueMove (cognitive 16) ExcalidrawZ/Persistence/CloudStorage/CloudStorageDocumentStore.swift:2473 — CloudStorageDocumentStore.enqueueMove has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalStorageManager.saveContent (cognitive 16) · ×1
  • LocalStorageManager.saveContent (cognitive 16) ExcalidrawZ/Persistence/FileStorage/LocalStorageManager.swift:101 — LocalStorageManager.saveContent has cognitive complexity 16 (threshold 15). Drivers by points: error handling 4 (9 pts), if/else 4 (6 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MigrationManager.checkMigrationsNeeded (cognitive 16) · ×1
  • MigrationManager.checkMigrationsNeeded (cognitive 16) ExcalidrawZ/Persistence/Migrations/MigrationManager.swift:41 — MigrationManager.checkMigrationsNeeded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (6 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFolderAvailabilityIndicator.monitorAvailability (cognitive 16) · ×1
  • LocalFolderAvailabilityIndicator.monitorAvailability (cognitive 16) ExcalidrawZ/Sidebar/Local/LocalFolderAvailabilityIndicator.swift:53 — LocalFolderAvailabilityIndicator.monitorAvailability has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), error handling 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TemporaryFileRowView.body (cognitive 16) · ×1
  • TemporaryFileRowView.body (cognitive 16) ExcalidrawZ/Sidebar/Temporary/TemporaryFileRowView.swift:23 — TemporaryFileRowView.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileHomeItemAppearanceModifier.background (cognitive 16) · ×1
  • FileHomeItemAppearanceModifier.background (cognitive 16) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:317 — FileHomeItemAppearanceModifier.background has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 7 (14 pts), if/else 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawCore.handleCopy (cognitive 16) · ×1
  • ExcalidrawCore.handleCopy (cognitive 16) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/ExcalidrawCore+ScriptMessage.swift:316 — ExcalidrawCore.handleCopy has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 2 (4 pts), loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawCore.loadPDFAsTiledImages (cognitive 16) · ×1
  • ExcalidrawCore.loadPDFAsTiledImages (cognitive 16) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+PDF.swift:84 — ExcalidrawCore.loadPDFAsTiledImages has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExcalidrawDocumentSnapshotCoordinator.commitDirtySnapshot (cognitive 16) · ×1
  • ExcalidrawDocumentSnapshotCoordinator.commitDirtySnapshot (cognitive 16) ExcalidrawZ/ExcalidrawView/Engine/Snapshot/ExcalidrawDocumentSnapshotCoordinator.swift:188 — ExcalidrawDocumentSnapshotCoordinator.commitDirtySnapshot has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 5, error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SyncCoordinator.checkForICloudUpdate (cognitive 16) · ×1
  • SyncCoordinator.checkForICloudUpdate (cognitive 16) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/SyncCoordinator.swift:691 — SyncCoordinator.checkForICloudUpdate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WebFetchTool.execute (cognitive 16) · ×1
  • WebFetchTool.execute (cognitive 16) ExcalidrawZ/SidebarTrailing/AIChat/Tools/WebFetchTool.swift:32 — WebFetchTool.execute has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 6, error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CompactBrowseRootView.content (cognitive 16) · ×1
  • CompactBrowseRootView.content (cognitive 16) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:81 — CompactBrowseRootView.content has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ImageURLResourceLoader.isBlockedHost (cognitive 16) · ×1
  • ImageURLResourceLoader.isBlockedHost (cognitive 16) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddOperation.swift:665 — ImageURLResourceLoader.isBlockedHost has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (8 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · JSONValue.collectImageSkeletonFileIDs (cognitive 16) · ×1
  • JSONValue.collectImageSkeletonFileIDs (cognitive 16) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+AddOperation.swift:139 — JSONValue.collectImageSkeletonFileIDs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), loops 2 (4 pts), ternaries 1 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ArchiveFilesModifier.swift.storedEncryptedContentIfPresent (cognitive 16) · ×1
  • ArchiveFilesModifier.swift.storedEncryptedContentIfPresent (cognitive 16) ExcalidrawZ/Utils/ArchiveFilesModifier.swift:663 — ArchiveFilesModifier.swift.storedEncryptedContentIfPresent has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (4 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LibraryImportSheetView.swift.handleDropExcalidrawLibrary (cognitive 16) · ×1
  • LibraryImportSheetView.swift.handleDropExcalidrawLibrary (cognitive 16) ExcalidrawZ/SidebarTrailing/Library/LibraryImportSheetView.swift:77 — LibraryImportSheetView.swift.handleDropExcalidrawLibrary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 1 (2 pts), error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Near-duplicate member family (10 members, 5 shared lines) · ×1
  • Near-duplicate member family (10 members, 5 shared lines) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11-25 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadBar.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityExactlyOne.swift:11-26 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootMany.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOne.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOneOrMany.swift:11-25 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadDiamond.swift:11-23 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadNone.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangle.swift:11-22 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangleOutline.swift:11-22 — These 10 members are variants of one another: a block of 5 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Near-duplicate member pair (9 shared lines) · ×1
  • Near-duplicate member pair (9 shared lines) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:21 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:21-42 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:55-76 — These two members are variants of one another: 9 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (32 corresponding lines) · ×1
  • Edited copy of a member (32 corresponding lines) ExcalidrawZ/ContentView+/Content+Searchable.swift:108 — ExcalidrawZ/ContentView+/Content+Searchable.swift:108-158 | ExcalidrawZ/ContentView+/Content+Searchable.swift:445-491 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (12 corresponding lines) · ×1
  • Edited copy of a member (12 corresponding lines) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:140 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:140-157 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:161-172 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:73 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:73-127 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:121-178 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:272-321 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:79-129 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift:128-177 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:98-159 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:247-318 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:477-568 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:90-147 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:216-278 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (8 members, 50+ identical tokens) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:180 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:180-208 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:323-347 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:131-158 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:161-188 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:321-351 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:571-605 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:149-177 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:141-174 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (6 members, 50+ identical tokens) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:120 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:120-135 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:194-213 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:287-296 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:338-347 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:390-399 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:656-665 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (5 members, 50+ identical tokens) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:176 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:176-193 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:176-191 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:120-132 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RenameFileTool.swift:102-127 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RestoreFileHistoryTool.swift:194-206 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Duplicated block (46 lines × 10) · ×1
  • Duplicated block (46 lines × 10) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:76 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:76-121 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:123-168 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:274-319 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:82-127 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift:131-176 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:101-146 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:249-294 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:479-524 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:93-138 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:219-264 — before extracting anything, compare `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:75` calls `encode` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:122` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (43–44 lines × 3) · ×1
  • Duplicated block (43–44 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:163 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:163-205 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift:185-228 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveOAuthAuthenticator.swift:277-320 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxOAuthAuthenticator.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxOAuthAuthenticator.swift:163` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (44 lines × 2) · ×1
  • Duplicated block (44 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:332 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:332-375 | ExcalidrawZ/SidebarTrailing/AIChat/components/ToolCards/AIProposalToolResultCard.swift:324-367 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (41 lines × 2) · ×1
  • Duplicated block (41 lines × 2) ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:90 — ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:90-130 | ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:161-201 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:90` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:160` calls `fileScopePredicate` and `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:89` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×1
  • Duplicated block (39 lines × 2) ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:166 — ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:166-204 | ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:227-265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/MediaItemRepository.swift:166` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×1
  • Duplicated block (32 lines × 2) ExcalidrawZ/ContentView+/Content+Searchable.swift:108 — ExcalidrawZ/ContentView+/Content+Searchable.swift:108-139 | ExcalidrawZ/ContentView+/Content+Searchable.swift:445-476 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Content+Searchable.swift:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×1
  • Duplicated block (30 lines × 2) ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:52 — ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:52-81 | ExcalidrawZ/Persistence/FileStorage/SyncCoordinator/FileEnumerator.swift:138-167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18–29 lines × 2) · ×1
  • Duplicated block (18–29 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:252 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:252-280 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:689-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:252` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (27–28 lines × 3) · ×1
  • Duplicated block (27–28 lines × 3) ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:200 — ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:200-227 | ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:234-261 | ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:311-337 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/NativeRenderer/ExcalidrawRenderer.swift:200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×1
  • Duplicated block (28 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:197 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:197-224 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:502-529 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:197` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (27–28 lines × 2) · ×1
  • Duplicated block (27–28 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:261 — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:261-287 | ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:339-366 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+Actions.swift:261` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×1
  • Duplicated block (27 lines × 2) ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:269 — ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:269-295 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:180-206 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×1
  • Duplicated block (25 lines × 2) ExcalidrawZ/ExcalidrawView/components/ExcalidrawFileCover.swift:450 — ExcalidrawZ/ExcalidrawView/components/ExcalidrawFileCover.swift:450-474 | ExcalidrawZ/ExcalidrawView/components/ExcalidrawFileCover.swift:491-515 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/ExcalidrawFileCover.swift:450` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16–24 lines × 4) · ×1
  • Duplicated block (16–24 lines × 4) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:59 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:59-78 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:135-150 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:37-60 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryFileHistoryTool.swift:34-49 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:59` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×1
  • Duplicated block (24 lines × 2) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:84 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:84-107 | ExcalidrawZ/SidebarTrailing/DebugPanel/DebugPanelView+Diagnostics.swift:238-261 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (23 lines × 7) · ×1
  • Duplicated block (23 lines × 7) ExcalidrawZ/Models/ExcalidrawElement.swift:84 — ExcalidrawZ/Models/ExcalidrawElement.swift:84-106 | ExcalidrawZ/Models/ExcalidrawElement.swift:111-133 | ExcalidrawZ/Models/ExcalidrawElement.swift:136-158 | ExcalidrawZ/Models/ExcalidrawElement.swift:161-183 | ExcalidrawZ/Models/ExcalidrawElement.swift:186-208 | ExcalidrawZ/Models/ExcalidrawElement.swift:211-233 | ExcalidrawZ/Models/ExcalidrawElement.swift:236-258 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (19–23 lines × 2) · ×1
  • Duplicated block (19–23 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:394 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:394-412 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphClient.swift:301-323 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (16–23 lines × 2) · ×1
  • Duplicated block (16–23 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:242 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:242-264 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:232-247 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:242` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×1
  • Duplicated block (23 lines × 2) ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:196 — ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:196-218 | ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:224-246 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:196` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:222` calls `WhatsNewVersionSection` and `ExcalidrawZ/components/WhatsNew/WhatsNewSheetView+allFeatures.swift:194` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (21–22 lines × 8) · ×1
  • Duplicated block (21–22 lines × 8) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:182 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:182-202 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:325-345 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:133-154 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:163-184 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:323-343 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:573-593 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:151-172 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:143-164 — before extracting anything, compare `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (22 lines × 6) · ×1
  • Duplicated block (22 lines × 6) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:381 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:381-402 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:534-555 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:564-585 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:594-615 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:624-645 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:654-675 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:381` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:588` calls `simplifyCrop` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:403` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×1
  • Duplicated block (22 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Box/BoxModels.swift:199 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxModels.swift:199-220 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxModels.swift:183-204 | ExcalidrawZ/Persistence/CloudStorage/OneDrive/OneDriveGraphModels.swift:88-109 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×1
  • Duplicated block (22 lines × 2) ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:326 — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:326-347 | ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:569-590 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:326` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift:591` calls `frame` and `ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:348` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–20 lines × 2) · ×1
  • Duplicated block (17–20 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:633 — ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:633-649 | ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactCloudStorageBrowserView.swift:218-237 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:633` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–19 lines × 4) · ×1
  • Duplicated block (17–19 lines × 4) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:82 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:82-100 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:78-94 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:84-100 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:97-113 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (19 lines × 4) · ×1
  • Duplicated block (19 lines × 4) ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:109 — ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:109-127 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:225-243 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:341-359 | ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:443-461 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Migrations/2_MoveContentToICloudDrive.swift:109` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×1
  • Duplicated block (19 lines × 3) ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:536 — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:536-554 | ExcalidrawZ/ExcalidrawView/Collaboration/CollaborationEditor.swift:271-289 | ExcalidrawZ/ExcalidrawView/Editor/ExcalidrawEditorOverlayModifier.swift:182-200 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift:536` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–19 lines × 3) · ×1
  • Duplicated block (14–19 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:249 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:249-267 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:686-699 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:237-250 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:278` calls `scrollToBottom` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift:251` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:70 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:70-88 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:51-67 — before extracting anything, compare `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:70` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×1
  • Duplicated block (16–17 lines × 3) ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:138 — ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:138-153 | ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:180-195 | ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:222-238 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift:138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–17 lines × 2) · ×1
  • Duplicated block (9–17 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:213 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:213-221 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:92-108 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–17 lines × 2) · ×1
  • Duplicated block (12–17 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:287 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:287-303 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:297-308 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:287` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–17 lines × 2) · ×1
  • Duplicated block (15–17 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:509 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:509-525 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:804-818 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:509` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:527` calls `dismantleNSView`, `removeObserver` and `ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:819` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 5) · ×1
  • Duplicated block (16 lines × 5) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:392 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:392-407 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:422-437 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:545-560 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:635-650 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:665-680 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×1
  • Duplicated block (16 lines × 3) ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:35 — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:35-50 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:42-57 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:55-70 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:332 — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:332-347 | ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift:317-330 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×1
  • Duplicated block (15 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:441 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:441-455 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:472-486 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:503-517 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:441` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (10–15 lines × 2) · ×1
  • Duplicated block (10–15 lines × 2) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:201 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:201-210 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ExportTool.swift:88-102 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:201` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13 lines × 4) · ×1
  • Duplicated block (13 lines × 4) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:124 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:124-136 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:172-184 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:194-206 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:217-229 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:124` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&item.updated) newElements[targetIndex] = .text(item) case .generic(var` in one and `&item.updated) newElements[targetIndex] = .linear(item) case .arrow(var` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×1
  • Duplicated block (13 lines × 3) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:299 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:299-311 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:528-540 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:554-566 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:299` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:297` calls `encodeIfPresent` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:526` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–13 lines × 3) · ×1
  • Duplicated block (6–13 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:62 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:62-74 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AppContextTools.swift:206-211 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:40-52 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:62` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×1
  • Duplicated block (12–13 lines × 2) ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:500 — ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:500-511 | ExcalidrawZ/ContentView+/Detail/Home/FileHomeView.swift:170-182 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactBrowseRootView.swift:500` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12 lines × 5) · ×1
  • Duplicated block (12 lines × 5) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:48 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:48-59 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:122-133 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:170-181 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:192-203 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:215-226 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&item.updated) newElements[targetIndex] = .text(item) case .generic(var` in one and `&item.updated) newElements[targetIndex] = .linear(item) case .arrow(var` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:60` calls `Int`, `parseTextAlign` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AdjustElementsTool/AdjustElementsTool+UpdateOperation.swift:134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–12 lines × 4) · ×1
  • Duplicated block (10–12 lines × 4) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:66 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:66-77 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:64-73 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:70-79 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:83-92 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53 — ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53-63 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:89-99 | ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:120-131 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Toolbar/ApplePencilToolbar/PencilTipsSheetView.swift:53` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10–11 lines × 4) · ×1
  • Duplicated block (10–11 lines × 4) ExcalidrawZ/Utils/Utils.swift:353 — ExcalidrawZ/Utils/Utils.swift:353-362 | ExcalidrawZ/Utils/Utils.swift:391-400 | ExcalidrawZ/Utils/Utils.swift:434-444 | ExcalidrawZ/Utils/Utils.swift:476-485 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Utils/Utils.swift:353` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×1
  • Duplicated block (9–11 lines × 2) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:126 — ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:126-136 | ExcalidrawZ/Store/LocalFolderState.swift:173-181 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:126` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 13) · ×1
  • Duplicated block (10 lines × 13) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:104 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:104-113 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:151-160 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:302-311 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:110-119 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift:159-168 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:129-138 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:277-286 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:298-307 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:507-516 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:527-536 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:553-562 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:121-130 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:247-256 — before extracting anything, compare `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:114` calls `encodeIfPresent` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:537` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–10 lines × 3) · ×1
  • Duplicated block (8–10 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:179 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:179-188 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:123-130 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RestoreFileHistoryTool.swift:197-204 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:179` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–10 lines × 2) · ×1
  • Duplicated block (8–10 lines × 2) ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:293 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:293-302 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveAPIClient.swift:288-295 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/CloudStorage/Box/BoxAPIClient.swift:293` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
D4 · Code Duplication · Duplicated block (9 lines × 11) · ×1
  • Duplicated block (9 lines × 11) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:105 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:105-113 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:152-160 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:303-311 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawGenricElement.swift:111-119 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawIframeLikeElement.swift:160-168 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawImageElement.swift:130-138 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:278-286 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:508-516 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:543-551 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawPdfElement.swift:122-130 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:248-256 — before extracting anything, compare `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFrameLikeElement.swift:102` calls `encode` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:541` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 10) · ×1
  • Duplicated block (9 lines × 10) ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:699 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:699-707 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:709-717 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:719-727 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:729-737 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:739-747 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:749-757 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:759-767 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:769-777 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:779-787 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ReadFileTool/ReadFileTool.swift:789-797 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8–9 lines × 4) · ×1
  • Duplicated block (8–9 lines × 4) ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:55 — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:55-63 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:81-89 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:28-36 | ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ViewportHelpers.swift:134-141 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:55` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+ElementHelpers.swift:37` calls `scheduleProgrammaticMutationCommit` and `ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCore/Helpers/ExcalidrawCore+AICameraHelpers.swift:64` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–8 lines × 2) · ×1
  • Duplicated block (6–8 lines × 2) ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:136 — ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:136-143 | ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:679-684 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Persistence/Repository/AIConversationRepository.swift:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (4–8 lines × 3) · ×1
  • Duplicated block (4–8 lines × 3) ExcalidrawZ/SidebarTrailing/AIChat/Tools/CalculatorTool.swift:34 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/CalculatorTool.swift:34-41 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/DateTimeTool.swift:43-50 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/FinalAnswerTool.swift:33-36 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/FinalAnswerTool.swift:33` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/SidebarTrailing/AIChat/Tools/CalculatorTool.swift:34` calls `ensureAIEnabled` and `ExcalidrawZ/SidebarTrailing/AIChat/Tools/FinalAnswerTool.swift:33` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×1
  • Duplicated block (6 lines × 6) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:128 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:128-135 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:207-213 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:291-296 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:342-347 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:394-399 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:660-665 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:128` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–6 lines × 6) · ×1
  • Duplicated block (4–6 lines × 6) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:273 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:273-278 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:311-314 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:324-329 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:363-366 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:376-381 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:421-424 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:273` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:424` calls `CGPoint`, `addLine` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:278` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–6 lines × 6) · ×1
  • Duplicated block (3–6 lines × 6) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:222 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:222-225 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:227-232 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:234-239 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:240-242 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:244-246 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:247-249 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:222` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:227` calls `CGPoint` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:240` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (2–5 lines × 16) · ×1
  • Duplicated block (2–5 lines × 16) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadBar.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityExactlyOne.swift:11-16 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:30-31 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootMany.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOne.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOneOrMany.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOneOrMany.swift:20-21 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadDiamond.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadNone.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangle.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangleOutline.swift:11-15 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:140-144 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:150-151 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:161-165 | ExcalidrawZ/Store/ToolState.swift:589-593 — before extracting anything, compare `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadBar.swift` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOne.swift` as WHOLE FILES: 84% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:11` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCardinalityZeroOrMany.swift:31` calls `addLine`, `CGPoint` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:144` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • Duplicated block (5 lines × 5) ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:176 — ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:176-180 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/ListLibraryItemsTool.swift:176-180 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/QueryLibraryItemTool.swift:120-124 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RenameFileTool.swift:102-106 | ExcalidrawZ/SidebarTrailing/AIChat/Tools/RestoreFileHistoryTool.swift:194-198 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/SidebarTrailing/AIChat/Tools/AddLibraryItemToCanvasTool.swift:176` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (2–5 lines × 17) · ×1
  • Duplicated block (2–5 lines × 17) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:22 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:22-23 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadCowsFootOneOrMany.swift:18-19 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadDiamond.swift:19-23 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangle.swift:18-19 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangleOutline.swift:18-22 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:148-149 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:200-202 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:225-226 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:228-229 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:234-235 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:238-240 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:268-270 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:272-274 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:331-332 | ExcalidrawZ/Sidebar/components/FileRowLabel.swift:397-398 | ExcalidrawZ/Store/ToolState.swift:594-595 | ExcalidrawZ/Store/ToolState.swift:596-598 — there are 17 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 17 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadDiamond.swift:19` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadTriangle.swift:20` calls `addLine`, `CGPoint` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ArrowheadsIcon/ArrowheadArrow.swift:24` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (2–5 lines × 6) · ×1
  • Duplicated block (2–5 lines × 6) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:30 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:30-31 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:34-35 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:38-42 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:64-65 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:68-69 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:72-76 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:30` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (3–5 lines × 3) · ×1
  • Duplicated block (3–5 lines × 3) ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:145 — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:145-147 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:153-157 | ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:168-172 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:153` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:152` calls `addLine`, `CGPoint` and `ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/DrawingSettingsIcons.swift:145` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×1
  • Duplicated block (6 lines × 4) ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:102 — ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift:102-107 | ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift:96-101 | ExcalidrawZ/Persistence/CloudStorage/GoogleDrive/GoogleDriveCredentialStore.swift:102-107 | ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVCredentialStore.swift:115-120 — before extracting anything, compare `ExcalidrawZ/Persistence/CloudStorage/Box/BoxCredentialStore.swift` and `ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxCredentialStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×1
  • Duplicated block (9 lines × 4) ExcalidrawZ/Settings/SecuritySettingsView.swift:928 — ExcalidrawZ/Settings/SecuritySettingsView.swift:928-936 | ExcalidrawZ/Sidebar/components/LockedFileAccessSheet.swift:429-437 | ExcalidrawZ/SidebarTrailing/AIChat/components/AIEnableConsentSheet.swift:202-210 | ExcalidrawZ/components/RecoveryKeyInputSheet.swift:166-174 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `ExcalidrawZ/Settings/SecuritySettingsView.swift:928` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `5` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:46 — ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:46-54 | ExcalidrawZ/Sidebar/Local/LocalFileContextMenu.swift:206-214 | ExcalidrawZ/Sidebar/Temporary/TemporaryFileMenu.swift:101-109 | ExcalidrawZ/Sidebar/components/FileContextMenu.swift:57-65 | ExcalidrawZ/Sidebar/components/FileContextMenu.swift:231-239 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `file` to `file` in one and `File?` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (26 lines × 3) · ×1
  • Duplicated block (26 lines × 3) ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:87 — ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift:87-112 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:438-463 | ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:179-204 — before extracting anything, compare `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawFreeDrawElement.swift` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 113 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawTextElement.swift:178` calls `decode` and `ExcalidrawZ/Models/ExcalidrawElements/ExcalidrawLinearElement.swift:437` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
P1 · CI/CD gates · No CI pipeline · ×1
  • No CI pipeline — No CI workflow found (.github/workflows, azure-pipelines.yml, .gitlab-ci.yml, …) — changes aren't gated by an automated build/test.
Minor — 34 finding(s)
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:310 — `!animated || hoverSuppressed || !hoverAnimationsEnabled` appears character-identically in 2 files — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift, ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+ActionBar.swift:81 — `!hasActiveFileForAIAccessControl || !canToggleAIFileAccess` appears character-identically in 2 files — ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+ActionBar.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+CompactIOSFloatingInput.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift:360 — `!isAutomatic || !isSilentAutomaticUnlockError(error)` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/Editor/LockedFileUnlockView.swift, ExcalidrawZ/Settings/SecuritySettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift:234 — `!isStreaming || (!hasFinalCall && hasToolCallsStarted && !text.isEmpty)` appears character-identically in 2 files — ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundTableRows.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:296 — `!suppressed && pointerHoverState.isInside` appears character-identically in 2 files — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift, ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Persistence/CloudStorage/CloudStorageConnectionStore.swift:351 — `$0.providerID == account.providerID && $0.accountID == account.id` appears character-identically in 2 files — ExcalidrawZ/Persistence/CloudStorage/CloudStorageConnectionStore.swift, ExcalidrawZ/Persistence/CloudStorage/CloudStorageSyncService.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:266 — `(isStreaming && isPinnedToBottom.wrappedValue) || isProgrammaticScrollPendingToBottom` appears character-identically in 3 files — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Home/TemporarayFilesHome/TemporaryFilesHomeView.swift:51 — `NSEvent.modifierFlags.contains(.command) || NSEvent.modifierFlags.contains(.shift)` appears character-identically in 4 files — ExcalidrawZ/ContentView+/Detail/Home/TemporarayFilesHome/TemporaryFilesHomeView.swift, ExcalidrawZ/Sidebar/GroupListView.swift, ExcalidrawZ/Sidebar/Local/LocalFilesListView.swift, ExcalidrawZ/Sidebar/Temporary/TemporaryFileListView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ColorPicker/ColorButton.swift:78 — `adaptsToDarkMode && colorScheme == .dark` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ColorPicker/ColorButton.swift, ExcalidrawZ/ExcalidrawView/components/DrawingSettingsPanel/ColorPicker/ColorButtonGroup.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift:382 — `attachedWebView !== webView || webView.superview !== self` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawWebView.swift, ExcalidrawZ/ExcalidrawView/ScreenAnnotation/ScreenAnnotationWebView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatEditorOverlays.swift:68 — `compactAIChatIsGenerating || layoutState.isCompactAIChatReplyTickerVisible || layoutState.isCompactAIChatReplyStartPending` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatEditorOverlays.swift, ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift:113 — `content.role == .assistant && streamingMessageIDs.contains(content.id)` appears character-identically in 3 files — ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView+MessagePresentation.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/Messages/AssistantRoundView.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/StaticGroupsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactExcalidrawHomeView.swift:44 — `disableInteration || !fileHomeItemTransitionState.canShowExcalidrawCanvas` appears character-identically in 2 files — ExcalidrawZ/ContentView+/Detail/Home/CompactIOS/CompactExcalidrawHomeView.swift, ExcalidrawZ/ContentView+/Detail/Home/ExcalidrawHomeView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift:337 — `docHeight <= visibleHeight || visibleMaxY >= docHeight - pinThreshold` appears character-identically in 3 files — ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatScrollView.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatStackView.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/ChatScrollView/NativeChatTableView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:739 — `fileState.isAIChatConversationLoading || fileState.currentActiveFileIsInTrash` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift, ExcalidrawZ/SidebarTrailing/AIChat/AIChatIslandView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:573 — `fileType == .excalidrawPNG || fileType == .excalidrawSVG` appears character-identically in 3 files — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift, ExcalidrawZ/Sidebar/Local/LocalFileRowView.swift, ExcalidrawZ/Store/FileState.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+ActionBar.swift:85 — `hasActiveFileForAIAccessControl && canToggleAIFileAccess` appears character-identically in 2 files — ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+ActionBar.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/PromptInput/PromptInputView+CompactIOSFloatingInput.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Sidebar/GroupListView.swift:487 — `hoverAnimationsEnabled && !hoverSuppressed` appears character-identically in 3 files — ExcalidrawZ/Sidebar/GroupListView.swift, ExcalidrawZ/Sidebar/LinkedStorageSidebarSection.swift, ExcalidrawZ/Sidebar/components/SidebarRowModifier.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift:271 — `hoverEffectsEnabled && !hoverSuppressed && isHovered` appears character-identically in 2 files — ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemView.swift, ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Settings/BackupsSettings/BackupLockedPreviewView.swift:48 — `isUnlocking || !systemUnlockAvailability.isAvailable` appears character-identically in 2 files — ExcalidrawZ/Settings/BackupsSettings/BackupLockedPreviewView.swift, ExcalidrawZ/Settings/SecuritySettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift:428 — `layoutState.isInspectorPresented && layoutState.activeInspectorTab == tab` appears character-identically in 3 files — ExcalidrawZ/ExcalidrawView/Toolbar/CompactExcalidrawBottomToolbarContent.swift, ExcalidrawZ/ExcalidrawView/Toolbar/ExcalidrawToolbar.swift, ExcalidrawZ/SidebarTrailing/ExcalidrawTrailingControls.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift:71 — `llmState.pendingApprovalRequest != nil || fileState.isAIChatConversationLoading || fileState.currentActiveFileIsInTrash` appears character-identically in 2 files — ExcalidrawZ/ExcalidrawView/Editor/CompactAIChatInputOverlay.swift, ExcalidrawZ/SidebarTrailing/AIChat/components/AIChatView/AIChatView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift:389 — `operation == .createFile || operation == .createFolder` appears character-identically in 2 files — ExcalidrawZ/Persistence/CloudStorage/Dropbox/DropboxAPIClient.swift, ExcalidrawZ/Persistence/CloudStorage/WebDAV/WebDAVClient.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift:459 — `preCheckpointID != nil || postCheckpointID != nil` appears character-identically in 2 files — ExcalidrawZ/Utils/MCP/Bridge/ExcalidrawMCPAppBridge.swift, ExcalidrawZ/Utils/MCP/Optimized/ExcalidrawMCPLLMCoreToolAdapter.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate ExcalidrawZ/Sidebar/LinkedStorageAddMenu.swift:137 — `preparingProviderID != nil || !connections.connectingProviderIDs.isEmpty` appears character-identically in 2 files — ExcalidrawZ/Sidebar/LinkedStorageAddMenu.swift, ExcalidrawZ/Sidebar/LinkedStorageSidebarSection.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
X7 · Silent fallback defaults · Silent fallback default in catch · ×5
  • Silent fallback default in catch ExcalidrawZ/Settings/FontsSettingsView.swift:48 — `addedFonts` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
  • Silent fallback default in catch ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawCanvasView.swift:86 — `addedFonts` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
  • Silent fallback default in catch ExcalidrawZ/ExcalidrawView/Engine/ExcalidrawViewportStateStore.swift:57 — `previewRevision` turns every thrown error into `"none"` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
  • Silent fallback default in catch ExcalidrawZ/Sidebar/components/MoveToGroupMenu.swift:41 — `filesCount` turns every thrown error into `0` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
  • Silent fallback default in catch ExcalidrawZ/Sidebar/components/MoveToGroupMenu.swift:44 — `subgroupsCount` turns every thrown error into `0` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 1 of 1 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (152657 LoC, 1601 module-visible types across 116 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P3 · Security & performance tooling · No SAST · ×1
  • No SAST — No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) — this repository has no CI pipeline yet, so run it locally to clear the existing findings, then make it a step of the first workflow you add so a regression fails the build. What was searched, so you can tell an absence from a miss: the 0 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
Minor — 6 finding(s)
D12 · Dependency Hygiene · Outdated · ×6
  • Outdated: kingfisher — `kingfisher` is resolved at 8.12.0, but 8.14.0 is the newest release tagged on https://github.com/onevcat/Kingfisher.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update kingfisher` reaches this one with no change to Package.swift.
  • Outdated: microsoft-authentication-library-for-objc — `microsoft-authentication-library-for-objc` is resolved at 2.14.1, but 2.17.0 is the newest release tagged on https://github.com/AzureAD/microsoft-authentication-library-for-objc within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update microsoft-authentication-library-for-objc` reaches this one with no change to Package.swift.
  • Outdated: sparkle — `sparkle` is resolved at 2.10.0, but 2.10.1 is the newest release tagged on https://github.com/sparkle-project/Sparkle.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update sparkle` reaches this one with no change to Package.swift.
  • Outdated: swift-log — `swift-log` is resolved at 1.15.1, but 1.16.2 is the newest release tagged on https://github.com/apple/swift-log.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-log` reaches this one with no change to Package.swift.
  • Outdated: swift-openapi-runtime — `swift-openapi-runtime` is resolved at 1.12.2, but 1.13.3 is the newest release tagged on https://github.com/apple/swift-openapi-runtime within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-openapi-runtime` reaches this one with no change to Package.swift.
  • Outdated: swiftui-introspect — `swiftui-introspect` is resolved at 27.0.0, but 27.1.0 is the newest release tagged on https://github.com/siteline/swiftui-introspect within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swiftui-introspect` reaches this one with no change to Package.swift.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-482c8c3aebc64bc18a592a2c9aae479d/history.json --exit-code 0 --source .80artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-482c8c3aebc64bc18a592a2c9aae479d/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/watchdog-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt .0artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json
D31 · IaC & Container Securitytrivy—trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.0—
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 140 file(s) — `ExcalidrawZ/ContentView+/Detail/Components/FileHomeItemTransition.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileICloudStatusIndicator.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileICloudSyncStatusIndicator.swift`, `ExcalidrawZ/ContentView+/Detail/Components/FileItemSelectionModifier.swift`, `ExcalidrawZ/ContentView+/Detail/Components/HomeFolderItemView.swift`, … (+135 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.0—
D36 · Supply-chain Provenance & Signingprovenance—provenance: not applicable — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.0—
D37 · Vulnerability-disclosure Policydisclosure—disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json

Run 01a18781-b9a7-7b4c-afd2-f676299846b9 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md