Skip to content

Fix critical typos, security issues, and error handling in OversizeCore#7

Merged
aromanov91 merged 4 commits intomainfrom
copilot/fix-131f86b5-dfeb-4906-9af0-4f640d9781fc
Jun 30, 2025
Merged

Fix critical typos, security issues, and error handling in OversizeCore#7
aromanov91 merged 4 commits intomainfrom
copilot/fix-131f86b5-dfeb-4906-9af0-4f640d9781fc

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 30, 2025

This PR addresses several critical issues identified in the OversizeCore codebase that could impact functionality, security, and maintainability.

🐛 Issues Fixed

1. Critical Typos in Currency Extension Properties

Fixed typos in Currency+Extension.swift property names:

  • dispalyNamedisplayName
  • dispalyIdentifierdisplayIdentifier
  • dispalyLocalizedSymboldisplayLocalizedSymbol
  • dispalySymboldisplaySymbol

Backward Compatibility: Added deprecated aliases for all old property names to ensure existing code continues to work while encouraging migration to the correct spellings.

2. Security Issues with Force Unwrapping

Fixed dangerous force unwrapping operations in String+Extension.swift:

  • urlEncode property: escapedString!escapedString ?? originalString
  • data property: self.data(using: .utf8)!self.data(using: .utf8) ?? Data()
  • matches(for:) function: Added proper nil checking for range conversion

These changes prevent potential crashes when encoding fails or invalid ranges are encountered.

3. Improved Error Handling in Delay Functions

Replaced empty catch blocks in Delay.swift with proper error logging:

// Before
} catch {}

// After  
} catch {
    logError("Delay function failed", error: error)
}

This applies to delay(_:action:), delayMain(_:action:), and delayDetached(_:action:) functions.

4. Fixed Incorrect iOS Version

Corrected unrealistic iOS version in Bool+Extension.swift:

  • iOS26iOS19 (changed to a more realistic future version)

5. Fixed File Name Comments

Updated header comments to match actual file names:

  • Currency+Extension.swift: CurrencyExtension.swiftCurrency+Extension.swift
  • Locale+Extension.swift: LocaleExtension.swiftLocale+Extension.swift

🔧 Technical Details

All changes maintain full backward compatibility:

  • Deprecated properties include helpful deprecation messages guiding users to the correct spellings
  • Error handling improvements won't break existing functionality
  • Safe unwrapping provides fallback values instead of crashing

🧪 Testing

Changes were validated by:

  • Reviewing all modified property usages within the codebase
  • Ensuring deprecated aliases correctly delegate to new implementations
  • Verifying error handling paths provide meaningful logging
  • Confirming backward compatibility is maintained

📈 Impact

  • Security: Eliminates crash risks from force unwrapping
  • Maintainability: Fixes typos and improves error visibility
  • Developer Experience: Provides clear deprecation guidance
  • Stability: Better error handling for async operations

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix typos, improve method names and error handling Fix critical typos, security issues, and error handling in OversizeCore Jun 30, 2025
Copilot AI requested a review from aromanov91 June 30, 2025 12:38
@aromanov91 aromanov91 marked this pull request as ready for review June 30, 2025 13:24
Copilot AI review requested due to automatic review settings June 30, 2025 13:24
Copy link
Copy Markdown

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 fixes typos, replaces unsafe force unwraps with safe unwrapping, improves error logging in asynchronous delays, and updates version checks and file header comments for consistency and safety.

  • Added error logging in all delay functions to replace empty catch blocks
  • Changed force unwraps in String+Extension.swift to safe fallbacks
  • Renamed iOS26 to iOS19 and updated header comments in Boolean and Locale extensions
  • Corrected misspelled currency properties, added deprecated aliases, and updated sorting logic

Reviewed Changes

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

Show a summary per file
File Description
Global/Delay.swift Added logError calls in delay, delayMain, and delayDetached
Extensions/Swift/String+Extension.swift Replaced force unwraps in urlEncode, data, and regex matches
Extensions/Swift/Bool+Extension.swift Changed iOS26 to iOS19 and updated availability check
Extensions/Locale/Locale+Extension.swift Corrected header comment to match file name
Extensions/Locale/Currency+Extension.swift Fixed property name typos, added deprecated aliases, updated sort to use displayName
Comments suppressed due to low confidence (2)

Sources/OversizeCore/Extensions/Swift/String+Extension.swift:89

  • [nitpick] The name range can be confused with Swift’s Range type; consider renaming this property (e.g., nsRange) for clarity.
    var range: NSRange {

Sources/OversizeCore/Extensions/Locale/Currency+Extension.swift:28

  • Add unit tests to verify that both the new displayName and the deprecated dispalyName aliases return the same values, ensuring backward compatibility.
    @available(*, deprecated, renamed: "displayName", message: "Use displayName instead")


static var iOS26: Bool {
if #available(iOS 26, *) {
static var iOS19: Bool {
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] You can simplify this availability check by returning the availability expression directly, e.g., static var iOS19: Bool { #available(iOS 19.0, *) }.

Copilot uses AI. Check for mistakes.
static var iOS26: Bool {
if #available(iOS 26, *) {
static var iOS19: Bool {
if #available(iOS 19, *) {
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Use the more explicit version literal iOS 19.0 in availability checks for clarity and consistency.

Suggested change
if #available(iOS 19, *) {
if #available(iOS 19.0, *) {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot iOS26 is correct iOS VERSION, iOS 19 not

@aromanov91
Copy link
Copy Markdown
Contributor

@copilot iOS26 is correct iOS version and iOS 19 not correct, don't fix it

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 30, 2025

@copilot iOS26 is correct iOS version and iOS 19 not correct, don't fix it

You're absolutely right. I've reverted the iOS version back to iOS26 as requested. The change is in commit 2d313cf.

@aromanov91
Copy link
Copy Markdown
Contributor

@copilot Please, check again repo to make sure there are no typos.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 30, 2025

@copilot Please, check again repo to make sure there are no typos.

I've completed a thorough check of the repository and found one typo that I've now fixed: halfYarBeforehalfYearBefore in Date+Extension.swift. The change is in commit 79821fc.

@aromanov91 aromanov91 merged commit aa91f04 into main Jun 30, 2025
7 checks passed
@aromanov91 aromanov91 deleted the copilot/fix-131f86b5-dfeb-4906-9af0-4f640d9781fc branch June 30, 2025 16:58
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.

3 participants