tekumara / typos-lsp

Source code spell checker for Visual Studio Code, Neovim and other LSP clients
https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode
MIT License
162 stars 4 forks source link

refactor(tests): fix additional clippy warnings #71

Closed mikavilpas closed 1 month ago

mikavilpas commented 1 month ago

refactor: fix clippy warnings

This fixes warnings that were reported using bacon's clippy-all job.

All of the warnings were for https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

It seems to use these command line flags:

# NOTE: bacon seems to run the longer command below, but this shorter command
# will also reproduce the warnings
cargo clippy --all-targets

# this is the longer command that bacon seems to run
cargo clippy --all-targets \
    --color always \
    -- \
    -A clippy::bool_to_int_with_if \
    -A clippy::collapsible_else_if \
    -A clippy::collapsible_if \
    -A clippy::derive_partial_eq_without_eq \
    -A clippy::len_without_is_empty \
    -A clippy::get_first \
    -A clippy::while_let_on_iterator

I ran into this by accident and figured it might be a good idea to fix them. I researched this a bit and think in practice they will have little to no performance impact - this seems to be motivated by simplicity and readability.

Here is the list of warnings that are generated by that command:

Details

Here is the list of warnings that are generated by that command: ```sh 1 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:182:24 | 182 | server.request(&did_open_diag_txt).await, | ^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_diag_txt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default 2 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:188:24 | 188 | server.request(&did_open_changelog_md).await, | ^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_changelog_md` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 3 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:194:24 | 194 | server.request(&did_open_skip_me).await, | ^^^^^^^^^^^^^^^^^ help: change this to: `did_open_skip_me` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 4 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:223:24 | 223 | server.request(&did_open_diag_txt).await, | ^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_diag_txt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 5 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:250:24 | 250 | server.request(&did_open_diag_txt).await, | ^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_diag_txt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 6 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:266:24 | 266 | server.request(&did_open_diag_txt).await, | ^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_diag_txt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 7 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:285:24 | 285 | server.request(&did_open_diag_txt).await, | ^^^^^^^^^^^^^^^^^^ help: change this to: `did_open_diag_txt` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 8 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:301:24 | 301 | server.request(&unicode_text).await, | ^^^^^^^^^^^^^ help: change this to: `unicode_text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 9 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:308:24 | 308 | server.request(&unicode_text).await, | ^^^^^^^^^^^^^ help: change this to: `unicode_text` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow 10 warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/typos-lsp/tests/integration_test.rs:323:24 | 323 | server.request(&did_open).await, | ^^^^^^^^^ help: change this to: `did_open` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow ```

ci: run clippy for all targets

I also added the extra --all-targets flag to the clippy job in the CI pipeline.

tekumara commented 1 month ago

Thank you! I've moved the borrow onto the function call for consistency with other usages.