taoky / tsumugu

🧵 A HTTP(S) mirroring tool written in Rust, proposed for ustcmirror
https://crates.io/crates/tsumugu
MIT License
17 stars 2 forks source link

Reduce cognitive complexity #5

Closed taoky closed 11 months ago

taoky commented 11 months ago
warning: the function has a cognitive complexity of (41/25)
  --> src/cli/sync.rs:67:8
   |
67 | pub fn sync(args: SyncArgs, bind_address: Option<String>) -> ! {
   |        ^^^^
   |
   = help: you could split it up into multiple smaller functions
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
note: the lint level is defined here
  --> src/main.rs:1:9
   |
1  | #![warn(clippy::cognitive_complexity)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: the function has a cognitive complexity of (62/25)
   --> src/cli/sync.rs:201:30
    |
201 |             scope.spawn(move || {
    |                              ^^
    |
    = help: you could split it up into multiple smaller functions
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity

warning: `tsumugu` (bin "tsumugu") generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.87s
taoky commented 11 months ago

After yesterday's commits:

warning: this function has too many lines (220/100)
   --> src/cli/sync.rs:196:1
    |
196 | / fn sync_threads(args: &SyncArgs, parser: &dyn crate::parser::Parser, options: &ThreadsOptions) {
197 | |     let exclusion_manager = ExclusionManager::new(&args.exclude, &args.include);
198 | |
199 | |     let client = build_client!(
...   |
450 | |     });
451 | | }
    | |_^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
note: the lint level is defined here
   --> src/main.rs:2:9
    |
2   | #![warn(clippy::too_many_lines)]
    |         ^^^^^^^^^^^^^^^^^^^^^^

warning: the function has a cognitive complexity of (52/25)
   --> src/cli/sync.rs:237:25
    |
237 |             scope.spawn(|| {
    |                         ^^
    |
    = help: you could split it up into multiple smaller functions
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
note: the lint level is defined here
   --> src/main.rs:1:9
    |
1   | #![warn(clippy::cognitive_complexity)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `tsumugu` (bin "tsumugu") generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
taoky commented 11 months ago

https://github.com/taoky/tsumugu/commit/5fd44191ed17bd780883579cbe8bd336b9950dfa