Skip to content

fix: update CropInfo initializer calls to use named argument labels#506

Merged
guoyingtao merged 2 commits intomasterfrom
fix/unit-tests
Feb 28, 2026
Merged

fix: update CropInfo initializer calls to use named argument labels#506
guoyingtao merged 2 commits intomasterfrom
fix/unit-tests

Conversation

@guoyingtao
Copy link
Owner

@guoyingtao guoyingtao commented Feb 28, 2026

CropInfo's init signature was updated with named parameters but FakeCropView.swift still used positional arguments, preventing the test target from compiling.

Summary by CodeRabbit

  • Tests
    • Refactored mock test utilities for improved readability and consistent test data construction. This enhances test clarity and maintainability while preserving existing behavior and test outcomes.

CropInfo's init signature was updated with named parameters but
FakeCropView.swift still used positional arguments, preventing the
test target from compiling.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af84c96 and 48887e4.

📒 Files selected for processing (1)
  • Tests/MantisTests/Mock/FakeCropView.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • Tests/MantisTests/Mock/FakeCropView.swift

📝 Walkthrough

Walkthrough

Adds a helper makeCropInfo() to FakeCropView.swift and replaces inline CropInfo constructions in crop(), crop(_ image:), and getCropInfo() with calls to this factory, keeping behavior identical while centralizing initialization.

Changes

Cohort / File(s) Summary
Test Mock: CropInfo factory
Tests/MantisTests/Mock/FakeCropView.swift
Introduced makeCropInfo() that returns a CropInfo with explicit named fields; replaced three inline CropInfo initializations (crop(), crop(_ image:), getCropInfo()) to call the new factory method.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 I stitched a little helper today,

makeCropInfo clears the way,
No more duplicates in the night,
One tiny hop, and code feels right 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating CropInfo initializer calls to use named argument labels, which directly addresses the compilation issue in FakeCropView.swift.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/unit-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Tests/MantisTests/Mock/FakeCropView.swift (1)

175-178: Consider centralizing the zero-value CropInfo mock builder.

You now have the same initializer payload in three places; extracting a helper will reduce future signature-drift risk in tests.

♻️ Optional refactor
+    private func makeZeroCropInfo() -> CropInfo {
+        CropInfo(
+            translation: .zero,
+            rotation: .zero,
+            scaleX: .zero,
+            scaleY: .zero,
+            cropSize: .zero,
+            imageViewSize: .zero,
+            cropRegion: CropRegion(topLeft: .zero, topRight: .zero, bottomLeft: .zero, bottomRight: .zero)
+        )
+    }
+
     func crop() -> CropOutput {
         CropOutput(nil,
                    Transformation(offset: .zero,
                                   rotation: .zero,
                                   scale: .zero,
                                   isManuallyZoomed: false,
                                   initialMaskFrame: .zero,
                                   maskFrame: .zero,
                                   cropWorkbenchViewBounds: .zero,
                                   horizontallyFlipped: false,
                                   verticallyFlipped: false),
-                   CropInfo(translation: .zero, rotation: .zero, scaleX: .zero, scaleY: .zero, cropSize: .zero, imageViewSize: .zero,
-                            cropRegion: CropRegion(topLeft: .zero,
-                                       topRight: .zero,
-                                       bottomLeft: .zero,
-                                       bottomRight: .zero)))
+                   makeZeroCropInfo())
     }

     func crop(_ image: UIImage) -> CropOutput {
         CropOutput(nil,
                    Transformation(offset: .zero,
                                   rotation: .zero,
                                   scale: .zero,
                                   isManuallyZoomed: false,
                                   initialMaskFrame: .zero,
                                   maskFrame: .zero,
                                   cropWorkbenchViewBounds: .zero,
                                   horizontallyFlipped: false,
                                   verticallyFlipped: false),
-                   CropInfo(translation: .zero, rotation: .zero, scaleX: .zero, scaleY: .zero, cropSize: .zero, imageViewSize: .zero,
-                            cropRegion: CropRegion(topLeft: .zero,
-                                       topRight: .zero,
-                                       bottomLeft: .zero,
-                                       bottomRight: .zero)))
+                   makeZeroCropInfo())
     }

     func getCropInfo() -> CropInfo {
-        CropInfo(translation: .zero, rotation: .zero, scaleX: .zero, scaleY: .zero,
-                 cropSize: .zero, imageViewSize: .zero,
-                 cropRegion: CropRegion(topLeft: .zero, topRight: .zero,
-                                        bottomLeft: .zero, bottomRight: .zero))
+        makeZeroCropInfo()
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Tests/MantisTests/Mock/FakeCropView.swift` around lines 175 - 178, Extract a
single test helper that returns the zero-valued CropInfo used by tests (e.g.,
makeZeroCropInfo() or zeroCropInfo()) and replace the repeated inline
initializer occurrences with calls to that helper; ensure the helper constructs
CropInfo(translation: .zero, rotation: .zero, scaleX: .zero, scaleY: .zero,
cropSize: .zero, imageViewSize: .zero, cropRegion: CropRegion(topLeft: .zero,
topRight: .zero, bottomLeft: .zero, bottomRight: .zero)) so all three usages of
CropInfo are consolidated and future signature changes only need one update.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Tests/MantisTests/Mock/FakeCropView.swift`:
- Around line 175-178: Extract a single test helper that returns the zero-valued
CropInfo used by tests (e.g., makeZeroCropInfo() or zeroCropInfo()) and replace
the repeated inline initializer occurrences with calls to that helper; ensure
the helper constructs CropInfo(translation: .zero, rotation: .zero, scaleX:
.zero, scaleY: .zero, cropSize: .zero, imageViewSize: .zero, cropRegion:
CropRegion(topLeft: .zero, topRight: .zero, bottomLeft: .zero, bottomRight:
.zero)) so all three usages of CropInfo are consolidated and future signature
changes only need one update.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a86001e and af84c96.

📒 Files selected for processing (1)
  • Tests/MantisTests/Mock/FakeCropView.swift

…nfo construction

Co-Authored-By: Claude <noreply@anthropic.com>
@guoyingtao guoyingtao merged commit a12c1b8 into master Feb 28, 2026
1 check passed
@guoyingtao guoyingtao deleted the fix/unit-tests branch February 28, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant