Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow exceptions to NoAssignmentInExpressions. #535

Merged
merged 1 commit into from
May 28, 2023

Conversation

allevato
Copy link
Member

This is mostly intended to carve out a really useful exception for testing: XCTAssertNoThrow(x = try ...) is quite a bit clearer about intent than x = try XCTUnwrap(try? ...) if you need the value x later in the test.

In an effort to not be too specific in this rule, I've opted to make this a configurable list of exceptions that by default contains XCTAssertNoThrow. So it only handles function calls right now, but this could be made more flexible in the future.

This is mostly intended to carve out a really useful exception for
testing: `XCTAssertNoThrow(x = try ...)` is quite a bit clearer about
intent than `x = try XCTUnwrap(try? ...)` if you need the value `x`
later in the test.

In an effort to not be *too* specific in this rule, I've opted to
make this a configurable list of exceptions that by default contains
`XCTAssertNoThrow`. So it only handles function calls right now, but
this could be made more flexible in the future.
@allevato
Copy link
Member Author

cc @dylansturg

@allevato allevato merged commit 3852bac into swiftlang:main May 28, 2023
@allevato allevato deleted the xctnothrow-assignment-fixes branch May 28, 2023 16:00
allevato added a commit to allevato/swift-format that referenced this pull request Jun 29, 2023
…fixes

Allow exceptions to `NoAssignmentInExpressions`.
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.

None yet

2 participants