Signal-iOS/SignalMessaging
Evan Hahn 04d7bb7462 Stop using arc4random in Swift files
This removes calls to `arc4random` and `arc4random_uniform` and replaces
them with calls to `Int.random` or equivalent.

These are a little less readable, which may be [why SwiftLint doesn't
like them][0]. (SwiftLint calls them "legacy", possibly because they're
not strong random number generators, but I couldn't find a clear
explanation for this anywhere, including [the original PR][1].)

This is the kind of change that's error-prone, so I wrote [a simple
script to help avoid regressions][2]. The script runs 10,000 iterations
of the old and new RNG and compares the ranges, reporting differences.
(Some differences are likely, like the ones that involve floats; others
are very unlikely to have differences.)

`git grep arc4random | grep swift` returns no results after this change.
Same for [everything else SwiftLint checks for][3].

[0]: https://realm.github.io/SwiftLint/legacy_random.html
[1]: https://github.com/realm/SwiftLint/pull/2419
[2]: https://gist.github.com/EvanHahn-Signal/9c75c9f484f4778149cbde3eafc9b285
[3]: ea6cc50890/Source/SwiftLintFramework/Rules/Idiomatic/LegacyRandomRule.swift (L23-L27)
2022-05-03 10:19:07 -05:00
..
attachments Fix typos 2022-03-18 11:31:06 -07:00
calls Fix some trivial compiler warnings 2022-04-19 09:28:15 -05:00
categories Stop using arc4random in Swift files 2022-05-03 10:19:07 -05:00
contacts Only send one PniIdentity sync message when there are many requests 2022-04-22 14:26:04 -07:00
environment Fetch phone numbers in a batch. 2022-03-17 12:46:33 -07:00
groups PR Feedback: Fix incorrect error case 2022-04-29 14:47:48 -07:00
Notifications Include timestamp in missed call notifications 2022-04-05 10:48:05 -07:00
Payments Prefer "blocklist" 2022-04-29 18:34:19 -05:00
profiles Add avatar repair. (#4091) 2022-04-29 10:14:05 -07:00
Storage Service Require transactions for the remainder of BlockingManager's interface 2022-04-08 19:01:43 -07:00
Subscriptions Fix typos: Reciept → Receipt 2022-04-29 12:14:09 -07:00
utils Simplify Searcher#matches 2022-04-29 12:56:54 -05:00
Info.plist Shared framework between app and extension 2017-11-29 13:58:27 -08:00
SignalMessaging-Prefix.pch minor changes due to changed name of NSLocalizedStringFromAppBundle (now OWSLocalizedString) and new location of swift function and preprocessor definition 2022-03-11 14:08:26 +01:00
SignalMessaging.h Copy in AFNetworking's query string encoding implementation 2021-12-17 14:52:59 -08:00