Skip to content

Instantly share code, notes, and snippets.

@timabell
Created February 18, 2023 10:36
Show Gist options
  • Save timabell/05f8def256546745c34cdc7f4886ad84 to your computer and use it in GitHub Desktop.
Save timabell/05f8def256546745c34cdc7f4886ad84 to your computer and use it in GitHub Desktop.
gitopolis clippy linting output, first rust lint ever
tim@max:~/repo/gitopolis (main)
$ cargo clippy
warning: this `else { if .. }` block can be collapsed
--> src/repos.rs:84:11
|
84 | } else {
| ____________________^
85 | | if !repo.tags.iter().any(|s| s == &tag_name.to_string()) {
86 | | repo.tags.push(tag_name.to_string());
87 | | }
88 | | }
| |_____________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
= note: `#[warn(clippy::collapsible_else_if)]` on by default
help: collapse nested if block
|
84 ~ } else if !repo.tags.iter().any(|s| s == &tag_name.to_string()) {
85 ~ repo.tags.push(tag_name.to_string());
86 ~ }
|
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/exec.rs:9:25
|
9 | repo_exec(&repo.path, &cmd, &args).expect("Failed to execute command.");
| ^^^^ help: change this to: `cmd`
|
= 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
warning: the borrowed expression implements the required traits
--> src/git.rs:16:37
|
16 | let repository = Repository::open(&path).map_err(|error| GitError {
| ^^^^^ help: change this to: `path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
warning: use of `expect` followed by a function call
--> src/git.rs:38:5
|
38 | .expect(&format!("Error running git clone"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error running git clone"))`
|
= 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: useless use of `format!`
--> src/git.rs:38:13
|
38 | .expect(&format!("Error running git clone"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"Error running git clone".to_string()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
= note: `#[warn(clippy::useless_format)]` on by default
warning: redundant clone
--> src/gitopolis.rs:36:30
|
36 | repos.add(normalized_folder.to_string(), url, remote_name);
| ^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> src/gitopolis.rs:36:13
|
36 | repos.add(normalized_folder.to_string(), url, remote_name);
| ^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
= note: `#[warn(clippy::redundant_clone)]` on by default
warning: redundant pattern matching, consider using `is_some()`
--> src/gitopolis.rs:28:10
|
28 | if let Some(_) = repos.repo_index(normalized_folder.to_owned()) {
| -------^^^^^^^------------------------------------------------- help: try this: `if repos.repo_index(normalized_folder.to_owned()).is_some()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
warning: returning the result of a `let` binding from a block
--> src/gitopolis.rs:108:2
|
107 | let state_toml = toml::to_string(&repos).expect("Failed to generate toml for repo list");
| ----------------------------------------------------------------------------------------- unnecessary `let` binding
108 | state_toml
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
= note: `#[warn(clippy::let_and_return)]` on by default
help: return the expression directly
|
107 ~
108 ~ toml::to_string(&repos).expect("Failed to generate toml for repo list")
|
warning: use of `expect` followed by a function call
--> src/gitopolis.rs:113:31
|
113 | toml::from_str(&state_toml).expect(&format!("Failed to parse {}", ".gitopolis.toml"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Failed to parse {}", ".gitopolis.toml"))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/gitopolis.rs:113:18
|
113 | toml::from_str(&state_toml).expect(&format!("Failed to parse {}", ".gitopolis.toml"));
| ^^^^^^^^^^^ help: change this to: `state_toml`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
warning: use of `expect` followed by a function call
--> src/gitopolis.rs:117:4
|
117 | .expect(&format!("Corrupted state file {}", ".gitopolis.toml"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Corrupted state file {}", ".gitopolis.toml"))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
warning: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec`
--> src/gitopolis.rs:123:4
|
123 | .into_iter()
| ^^^^^^^^^ help: call directly: `iter`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
= note: `#[warn(clippy::into_iter_on_ref)]` on by default
warning: single-character string constant used as pattern
--> src/gitopolis.rs:131:21
|
131 | .trim_end_matches("\\")
| ^^^^ help: try using a `char` instead: `'\\'`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
= note: `#[warn(clippy::single_char_pattern)]` on by default
warning: single-character string constant used as pattern
--> src/gitopolis.rs:130:21
|
130 | .trim_end_matches("/")
| ^^^ help: try using a `char` instead: `'/'`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
warning: you should consider adding a `Default` implementation for `Repos`
--> src/repos.rs:38:2
|
38 | / pub fn new() -> Self {
39 | | Self { repos: Vec::new() }
40 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
= note: `#[warn(clippy::new_without_default)]` on by default
help: try adding this
|
37 + impl Default for Repos {
38 + fn default() -> Self {
39 + Self::new()
40 + }
41 + }
|
warning: use of `expect` followed by a function call
--> src/repos.rs:64:6
|
64 | .expect(&format!("Repo '{}' not found", repo_folder));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Repo '{}' not found", repo_folder))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
warning: use of `expect` followed by a function call
--> src/repos.rs:79:6
|
79 | .expect(&format!("Repo '{}' not found", repo_folder));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Repo '{}' not found", repo_folder))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
warning: use of `expect` followed by a function call
--> src/storage.rs:36:36
|
36 | fs::write(self.path, state_toml).expect(&format!("Failed to write {}", self.path));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Failed to write {}", self.path))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#expect_fun_call
warning: `gitopolis` (lib) generated 18 warnings
warning: length comparison to zero
--> src/main.rs:123:5
|
123 | if repos.len() == 0 {
| ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `repos.is_empty()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
= note: `#[warn(clippy::len_zero)]` on by default
warning: `gitopolis` (bin "gitopolis") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment