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

Fix clippy error on Windows #1521

Merged
merged 2 commits into from
May 26, 2024
Merged

Fix clippy error on Windows #1521

merged 2 commits into from
May 26, 2024

Conversation

06393993
Copy link
Contributor

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

  • fixes those warnings
  • runs the lint CI on Windows as well
  • fail the CI if clippy results in any warnings
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> 

Copy link

codecov bot commented May 25, 2024

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 ⚠️
nextest-runner/src/errors.rs 0.00% 1 Missing ⚠️
nextest-runner/src/helpers.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This commit also makes the CI fail if there are clippy warnings on all
platforms.
@sunshowers
Copy link
Member

Thanks!

@sunshowers sunshowers merged commit 5992455 into nextest-rs:main May 26, 2024
16 checks passed
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.

2 participants