nextest-rs / nextest

A next-generation test runner for Rust.
https://nexte.st
Apache License 2.0
2.03k stars 90 forks source link

Fix clippy error on Windows #1521

Closed 06393993 closed 1 month ago

06393993 commented 1 month ago

cargo clippy --all-features --all-targets will result the following warnings on windows. This PR:

PS C:\Users\XXXXXXXX\src\nextest> cargo clippy --all-features --all-targets
    Checking nextest-runner v0.56.1 (C:\Users\XXXXXXXX\src\nextest\nextest-runner)
warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:58:10
     |
58   |       ) -> Result<Self, CargoConfigError> {
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
     = note: `#[warn(clippy::result_large_err)]` on by default

warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:96:10
     |
96   |       ) -> Result<Self, CargoConfigError> {
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:167:6
     |
167  |   ) -> Result<Vec<(CargoConfigSource, CargoConfig)>, CargoConfigError> {
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:186:42
     |
186  |   fn parse_cli_config(config_str: &str) -> Result<CargoConfig, CargoConfigError> {
     |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:293:6
     |
293  |   ) -> Result<Vec<(CargoConfigSource, CargoConfig)>, CargoConfigError> {
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

warning: the `Err`-variant returned from this function is very large
    --> nextest-runner\src\cargo_config\discovery.rs:367:6
     |
367  |   ) -> Result<(CargoConfigSource, CargoConfig), CargoConfigError> {
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: nextest-runner\src\errors.rs:1163:5
     |
1163 | /     ConfigParseError {
1164 | |         /// The path of the config file
1165 | |         path: Utf8PathBuf,
1166 | |
...    |
1169 | |         error: toml::de::Error,
1170 | |     },
     | |_____- the largest variant contains at least 128 bytes
     |
     = help: try reducing the size of `errors::CargoConfigError`, for example by boxing large elements or replacing it with `Box<errors::CargoConfigError>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

warning: unnecessary closure used with `bool::then`
   --> nextest-runner\src\helpers.rs:234:17
    |
234 |                 (code < 0).then(|| AbortStatus::WindowsNtStatus(code))
    |                 ^^^^^^^^^^^-------------------------------------------
    |                            |
    |                            help: use `then_some(..)` instead: `then_some(AbortStatus::WindowsNtStatus(code))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
    = note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default

warning: unneeded `return` statement
   --> nextest-runner\src\helpers.rs:274:5
    |
274 | /     return format!(
275 | |         "{:#x}: {}",
276 | |         nt_status,
277 | |         io::Error::from_raw_os_error(win32_code as i32)
278 | |     );
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
274 ~     format!(
275 +         "{:#x}: {}",
276 +         nt_status,
277 +         io::Error::from_raw_os_error(win32_code as i32)
278 ~     )
    |

warning: useless conversion to the same type: `std::string::String`
   --> nextest-runner\src\reporter\aggregator.rs:411:13
    |
411 | /             format!(
412 | |                 "Test aborted with code {}{}",
413 | |                 crate::helpers::display_nt_status(exception),
414 | |                 if leaked {
...   |
419 | |             )
420 | |             .into(),
    | |___________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default
help: consider removing `.into()`
    |
411 ~             format!(
412 +                 "Test aborted with code {}{}",
413 +                 crate::helpers::display_nt_status(exception),
414 +                 if leaked {
415 +                     ", and also leaked handles"
416 +                 } else {
417 +                     ""
418 +                 }
419 ~             ),
    |

warning: unnecessary closure used with `bool::then`
    --> nextest-runner\src\runner.rs:1179:21
     |
1179 |                     (code < 0).then(|| AbortStatus::WindowsNtStatus(code))
     |                     ^^^^^^^^^^^-------------------------------------------
     |                                |
     |                                help: use `then_some(..)` instead: `then_some(AbortStatus::WindowsNtStatus(code))`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations

warning: `nextest-runner` (lib) generated 10 warnings (run `cargo clippy --fix --lib -p nextest-runner` to apply 4 suggestions)
    Checking cargo-nextest v0.9.72 (C:\Users\XXXXXXXX\src\nextest\cargo-nextest)
warning: `nextest-runner` (lib test) generated 10 warnings (10 duplicates)
    Checking integration-tests v0.1.0 (C:\Users\XXXXXXXX\src\nextest\integration-tests)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.28s
PS C:\Users\XXXXXXXX\src\nextest> 
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 78.99%. Comparing base (aa72297) to head (652ce99).

Files Patch % Lines
nextest-runner/src/cargo_config/discovery.rs 50.00% 2 Missing :warning:
nextest-runner/src/errors.rs 0.00% 1 Missing :warning:
nextest-runner/src/helpers.rs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1521 +/- ## ========================================== - Coverage 79.01% 78.99% -0.02% ========================================== Files 76 76 Lines 18783 18785 +2 ========================================== - Hits 14841 14840 -1 - Misses 3942 3945 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sunshowers commented 1 month ago

Thanks!