Signal-iOS/SignalServiceKit/src
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
..
Account Reset the identity key if initial pre-key creation fails 2022-04-22 18:11:42 -07:00
Contacts PR Feedback: Remove notImplemented altogether 2022-04-13 20:21:47 -07:00
Devices Lint 2022-04-08 19:01:43 -07:00
groups Require transactions for the remainder of BlockingManager's interface 2022-04-08 19:01:43 -07:00
Messages Change references from master to main 2022-05-02 10:30:40 -05:00
Network Stop using arc4random in Swift files 2022-05-03 10:19:07 -05:00
Payments Add "Donation Receipts" view 2022-04-11 16:21:12 -05:00
Protocols Check if a user is stories capable when sending group replies 2022-03-31 00:37:56 -07:00
Protos Add initial support for the PniIdentity sync message 2022-03-23 11:48:08 -07:00
Remote Attestation Update to LibSignalClient v0.15.0 2022-03-24 11:55:45 -07:00
Security More Python 3 script fixes 2022-03-24 10:28:27 -05:00
Storage Fix deletion of a message after deleting all its attachments 2022-05-02 12:33:55 -07:00
TestUtils Stop using arc4random in Swift files 2022-05-03 10:19:07 -05:00
Util Stop using arc4random in Swift files 2022-05-03 10:19:07 -05:00
SignalServiceKit.h SSK: Collapse OWSMessageUtils into OWSMessageManager 2022-04-11 15:17:39 -07:00
SSKEnvironment.h Support two SignalProtocolStores in SSKEnvironment 2022-03-16 14:31:06 -07:00
SSKEnvironment.m Support two SignalProtocolStores in SSKEnvironment 2022-03-16 14:31:06 -07:00
TSConstants.swift Clean up donate URL code 2022-04-21 12:23:37 -05:00
TSPrefix.h Change phone number. 2021-11-19 14:28:18 -03:00