Skip to content

Improve multi-delay parsing and iOS coverage#702

Open
riderx wants to merge 1 commit intomainfrom
riderx/create-pr
Open

Improve multi-delay parsing and iOS coverage#702
riderx wants to merge 1 commit intomainfrom
riderx/create-pr

Conversation

@riderx
Copy link
Member

@riderx riderx commented Feb 16, 2026

What

  • Improve multi-delay date parsing on Android and iOS to support ISO-8601 variants (with/without fractional seconds and timezone).
  • Remove the unintended setDelay exposure from iOS plugin method registration and the web stub.
  • Add iOS unit tests for setMultiDelay persistence and kill-condition filtering, and add Android coverage for ISO dates without milliseconds.

Why

  • Delay conditions should be parsed consistently across platforms so multi-delay timing behaves predictably.

How

  • Introduced dedicated date parsing helpers in both native delay utilities and expanded platform tests around delay-condition retention logic.

Testing

  • bun run test:ios
  • bun run verify:android
  • bun run verify:ios
  • bun run build

Not Tested

  • End-to-end update delay behavior on physical devices.

Summary by CodeRabbit

  • Style

    • Improved code formatting in utility files.
  • Tests

    • Added test coverage for delay update cancellation behavior when sources are terminated.

Copilot AI review requested due to automatic review settings February 16, 2026 15:18
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 62479394-bfb5-4f9f-ad8b-3134b5d08fef

📥 Commits

Reviewing files that changed from the base of the PR and between f1291cc and ccba3f7.

📒 Files selected for processing (3)
  • android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java
  • android/src/test/java/ee/forgr/capacitor_updater/DelayUpdateUtilsTest.java
  • ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift
💤 Files with no reviewable changes (2)
  • android/src/test/java/ee/forgr/capacitor_updater/DelayUpdateUtilsTest.java
  • android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift

📝 Walkthrough

Walkthrough

This PR removes unnecessary blank lines from two Android source files and adds a new iOS test case to verify delay update cancellation behavior with killed conditions.

Changes

Cohort / File(s) Summary
Android Formatting
android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java, android/src/test/java/ee/forgr/capacitor_updater/DelayUpdateUtilsTest.java
Removed blank lines between method definitions for improved code style consistency.
iOS Test Addition
ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift
Added new test testDelayUpdateUtilsCheckCancelDelayKilledKeepsOtherConditions() to verify that canceling a delay with killed conditions preserves other delay conditions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

Poem

Whitespace whispers fade away,
While tests bloom bright to save the day,
A killer condition we now test,
Ensuring other delays rest,
Fresh hops through cleaner code we go! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 accurately captures the main objectives of the PR: improving multi-delay parsing (on Android and iOS) and adding iOS test coverage for delay utilities.

✏️ 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 riderx/create-pr
📝 Coding Plan
  • Generate coding plan for human review comments

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)
ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift (1)

153-163: do/catch around non-throwing code — catch block is unreachable.

UserDefaults.standard.set(...) and synchronize() don't throw. The catch block on Line 159 will never execute. This same pattern repeats in setBackgroundTimestamp, unsetBackgroundTimestamp, getBackgroundTimestamp, and cancelDelay.

Not blocking since this is pre-existing, but worth cleaning up to avoid misleading readers into thinking these operations can fail with a thrown error.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns multi-delay date parsing behavior across Android and iOS (supporting more ISO-8601 variants), removes the unintended setDelay exposure from iOS/web wiring, and expands native test coverage around multi-delay persistence and filtering.

Changes:

  • Add dedicated date parsing helpers on iOS/Android to accept ISO-8601 strings with/without fractional seconds and with/without timezone.
  • Remove setDelay from iOS bridged method registration and the web implementation stub.
  • Add iOS unit tests for setMultiDelay persistence and kill-condition filtering; add Android test coverage for ISO dates without milliseconds.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/web.ts Removes the web setDelay stub and associated type import.
ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift Adds iOS unit tests for multi-delay persistence and kill filtering (and imports Version).
ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift Introduces a helper to parse additional ISO-8601 date variants for delay conditions.
ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift Removes unintended setDelay exposure from plugin method registration.
android/src/test/java/ee/forgr/capacitor_updater/DelayUpdateUtilsTest.java Adds a regression test for ISO-8601 dates without milliseconds.
android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java Adds parseDateCondition to support ISO-8601 variants across timezones and fractional seconds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,5 +1,6 @@
import XCTest
@testable import CapacitorUpdaterPlugin
import Version
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

import Version in this test target will likely fail to compile under SwiftPM because CapacitorUpdaterPluginTests only declares a dependency on CapacitorUpdaterPlugin in Package.swift (SwiftPM targets can only import direct dependencies, not transitive ones). Add the Version product to the test target dependencies (or avoid importing it by constructing the needed value via the plugin module).

Suggested change
import Version

Copilot uses AI. Check for mistakes.
Comment on lines +224 to +231
// Legacy fallback for strings without timezone.
for format in ["yyyy-MM-dd'T'HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss"] {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = format
if let date = formatter.date(from: value) {
return date
}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

In the legacy timezone-less fallback, DateFormatter is created with a fixed dateFormat but no explicit calendar/timeZone. For users with a non-Gregorian current calendar (or unexpected timezone defaults), this can parse into an unintended absolute Date, causing delay conditions to be kept/removed incorrectly. Set formatter.calendar = Calendar(identifier: .gregorian) and formatter.timeZone = .current (or whatever “legacy” behavior is intended) to make parsing deterministic.

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1291cc8bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

sdf.setTimeZone(TimeZone.getDefault());
}

Date parsed = sdf.parse(value);

Choose a reason for hiding this comment

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

P2 Badge Reject partial matches in date fallback parsing

parseDateCondition falls back from timezone-aware patterns to timezone-less ones, but SimpleDateFormat.parse(String) here accepts trailing characters, so values that miss the XXX format (for example 2099-12-31T23:59:59+0000) can be parsed by the local-time fallback while silently discarding the offset suffix. That means date delays are evaluated in device local time instead of the requested offset on non-UTC devices, which can shift update timing by hours. Please require full-string consumption (e.g., via ParsePosition) or handle +HHMM/Z offset patterns before timezone-less fallbacks.

Useful? React with 👍 / 👎.

@riderx riderx force-pushed the riderx/create-pr branch from f1291cc to ccba3f7 Compare March 16, 2026 18:59
@sonarqubecloud
Copy link

@riderx
Copy link
Member Author

riderx commented Mar 16, 2026

Rebased this branch onto the latest main and resolved the conflicts manually.

Resolution summary:

  • Kept the newer main refactor that parses Android dates through the shared helper and preserved the stricter Swift fallback formatter setup.
  • Re-applied the PR-specific date coverage by keeping the extra Android compact-offset patterns (XX / X) and the matching Android test coverage.
  • Kept the newer test helpers from main where the PR and base branch had equivalent Swift test logic.

The branch is pushed and no longer behind main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants