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

run clippy on tests, fix findings #416

Merged
merged 7 commits into from
Apr 19, 2024
Merged

run clippy on tests, fix findings #416

merged 7 commits into from
Apr 19, 2024

Conversation

cpu
Copy link
Member

@cpu cpu commented Apr 5, 2024

Over in the rustls-openssl-compat repo that we bootstrapped from this repo's settings I noticed we weren't linting test code (rustls/rustls-openssl-compat#6). It looks like that's true for this repo as well.

This branch updates the clippy jobs to do so and fixes the findings that were present.

cpu added 7 commits April 5, 2024 16:12
```
warning: redundant pattern matching, consider using `is_err()`
   --> src/lib.rs:247:17
    |
247 |         assert!(matches!(userdata_get(), Err(_)));
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `userdata_get().is_err()`
```
```
warning: used `assert_eq!` with a literal bool
   --> src/client.rs:647:9
    |
647 | /         assert_eq!(
648 | |             rustls_connection::rustls_connection_is_handshaking(conn),
649 | |             true
650 | |         );
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
```
```
1163 | impl rustls_server_cert_verifier {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
     = note: `#[warn(clippy::items_after_test_module)]` on by default
     = help: move the items to before the test module was defined
```
```
warning: use of `expect` followed by a function call
   --> tests/client_server.rs:192:14
    |
192 |             .expect(&format!("failed to run server binary {server_binary}"))
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("failed to run server binary {server_binary}"))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
    = note: `#[warn(clippy::expect_fun_call)]` on by default
```
```
warning: this boolean expression can be simplified
   --> tests/client_server.rs:161:22
    |
161 |         let passed = result.status.success() == !self.expect_error;
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `result.status.success() != self.expect_error`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
    = note: `#[warn(clippy::nonminimal_bool)]` on by default

```
This ensures test code is also linted.
@cpu cpu self-assigned this Apr 5, 2024
@cpu cpu merged commit 3dc23ef into rustls:main Apr 19, 2024
21 checks passed
@cpu cpu deleted the cpu-clippy-fix branch April 19, 2024 13:38
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