-
Notifications
You must be signed in to change notification settings - Fork 450
[Clippy] Address most clippy issues in production code #1291
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
Merged
+260
−218
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
4924fc6
[Clippy] Address `clippy::missing_safety_doc` in src/apply.rs
DanielEScherzer 2acbfb7
[Clippy] Address `clippy::new_without_default` in src/apply.rs
DanielEScherzer 8d2f956
[Clippy] Address `clippy::redundant_closure` in src/blame.rs
DanielEScherzer d39ed7b
[Clippy] Address `clippy::io_other_error` in src/blob.rs
DanielEScherzer b6ea28b
[Clippy] Address `clippy::missing_safety_doc` in src/branch.rs
DanielEScherzer 6278c61
[Clippy] Address `clippy::explicit_auto_deref` in src/buf.rs
DanielEScherzer b2e1850
[Clippy] Address `clippy::manual_non_exhaustive` in src/build.rs
DanielEScherzer e2a5755
[Clippy] Address `clippy::missing_safety_doc` in src/build.rs
DanielEScherzer 95fab73
[Clippy] Address `clippy::needless_lifetimes` in src/call.rs
DanielEScherzer 5843bac
[Clippy] Address `clippy::new_without_default` in src/cherrypick.rs
DanielEScherzer a9aaab1
[Clippy] Address `clippy::redundant_closure` in src/commit.rs
DanielEScherzer 604553a
[Clippy] Address `clippy::should_implement_trait` in src/config.rs
DanielEScherzer 700a9cd
[Clippy] Address `clippy::manual_strip` in src/cred.rs
DanielEScherzer 493cd2f
[Clippy] Address `clippy::match_result_ok` in src/cred.rs
DanielEScherzer 2f79fce
[Clippy] Address `clippy::missing_safety_doc` in src/cred.rs
DanielEScherzer f96b066
[Clippy] Address `clippy::needless_borrowed_reference` in src/cred.rs
DanielEScherzer 4a235ba
[Clippy] Address `clippy::needless_borrows_for_generic_args` in src/c…
DanielEScherzer 889d37d
[Clippy] Address `clippy::should_implement_trait` in src/cred.rs
DanielEScherzer bba606e
[Clippy] Address `clippy::empty_docs` in src/diff.rs
DanielEScherzer d7f4900
[Clippy] Address `clippy::missing_safety_doc` in src/diff.rs
DanielEScherzer 894770c
[Clippy] Address `clippy::new_without_default` in src/diff.rs
DanielEScherzer 2ba47af
[Clippy] Address `clippy::too_many_arguments` in src/email.rs
DanielEScherzer 4a7521a
[Clippy] Address `clippy::should_implement_trait` in src/error.rs
DanielEScherzer d9cfd2d
[Clippy] Address `clippy::io_other_error` in src/indexer.rs
DanielEScherzer 9fc2de6
[Clippy] Address `clippy::needless_lifetimes` in src/lib.rs
DanielEScherzer eff593a
[Clippy] Address `clippy::should_implement_trait` in src/lib.rs
DanielEScherzer abe7300
[Clippy] Address `clippy::missing_safety_doc` in src/merge.rs
DanielEScherzer 50c5ff3
[Clippy] Address `clippy::redundant_closure` in src/merge.rs
DanielEScherzer ff07f2f
[Clippy] Address `clippy::len_without_is_empty` in src/message.rs
DanielEScherzer dcbf356
[Clippy] Address `clippy::needless_borrow` in src/message.rs
DanielEScherzer 8cfba67
[Clippy] Address `clippy::redundant_closure` in src/message.rs
DanielEScherzer 65b3df6
[Clippy] Address `clippy::io_error_other` in src/odb.rs
DanielEScherzer c063ce0
[Clippy] Address `clippy::len_without_is_empty` in src/odb.rs
DanielEScherzer 94dd707
[Clippy] Address `clippy::should_implement_trait` in src/odb.rs
DanielEScherzer 4598f25
[Clippy] Address `clippy::single_match` in src/odb.rs
DanielEScherzer 8bd58e6
[Clippy] Address `clippy::extra_unused_lifetimes` in src/oid_array.rs
DanielEScherzer 1609c60
[Clippy] Address `clippy::should_implement_trait` in src/oid.rs
DanielEScherzer 20a6c6b
[Clippy] Address `clippy::missing_safety_doc` in src/opts.rs
DanielEScherzer fd5ae26
[Clippy] Address `clippy::redundant_closure` in src/packbuilder.rs
DanielEScherzer 9fc8b06
[Clippy] Address `clippy::len_without_is_empty` in src/rebase.rs
DanielEScherzer 1a7ae6b
[Clippy] Address `clippy::needless_option_take` in src/rebase.rs
DanielEScherzer 3fee76e
[Clippy] Address `clippy::redundant_closure` in src/rebase.rs
DanielEScherzer 70271b9
[Clippy] Address `clippy::redundant_closure` in src/reference.rs
DanielEScherzer e04e144
[Clippy] Address `clippy::redundant_closure` in src/reflog.rs
DanielEScherzer d54058a
[Clippy] Address `clippy::derivable_impls` in src/remote.rs
DanielEScherzer a42b5cc
[Clippy] Address `clippy::empty_line_after_doc_comments` in src/remot…
DanielEScherzer 5937bce
[Clippy] Address `clippy::redundant_closure` in src/remote.rs
DanielEScherzer e9727fb
[Clippy] Address `clippy::unwrap_or_default` in src/remote.rs
DanielEScherzer 4dee9b9
[Clippy] Address `clippy::doc_overindented_list_items` in src/remote_…
DanielEScherzer 579ebdd
[Clippy] Address `clippy::explicit_auto_deref` in src/repo.rs
DanielEScherzer 01d626b
[Clippy] Address `clippy::missing_safety_doc` in src/repo.rs
DanielEScherzer 51d382a
[Clippy] Address `clippy::needless_borrow` in src/repo.rs
DanielEScherzer 872493f
[Clippy] Address `clippy::new_without_default` in src/repo.rs
DanielEScherzer cfcf761
[Clippy] Address `clippy::redundant_closure` in src/repo.rs
DanielEScherzer 0d00c84
[Clippy] Address `clippy::too_many_arguments` in src/repo.rs
DanielEScherzer fe53f31
[Clippy] Address `clippy::zero_ptr` in src/repo.rs
DanielEScherzer 7ed3393
[Clippy] Address `clippy::new_without_default` in src/revert.rs
DanielEScherzer 15815dc
[Clippy] Address `clippy::missing_safety_doc` in src/revert.rs
DanielEScherzer bf01979
[Clippy] Address `clippy::missing_safety_doc` in src/status.rs
DanielEScherzer e8a0834
[Clippy] Address `clippy::redundant_closure` in src/string_array.rs
DanielEScherzer 78570ef
[Clippy] Address `clippy::empty_line_after_doc_comments` in src/submo…
DanielEScherzer c5e2093
[Clippy] Address `clippy::let_and_return` in src/submodule.rs
DanielEScherzer 000ea52
[Clippy] Address `clippy::redundant_closure` in src/submodule.rs
DanielEScherzer 205f3c3
[Clippy] Address `clippy::from_over_into` in src/tag.rs
DanielEScherzer 3003bba
[Clippy] Address `clippy::redundant_closure` in src/tag.rs
DanielEScherzer de0a19a
[Clippy] Address `clippy::missing_safety_doc` in src/transport.rs
DanielEScherzer b84b7cb
[Clippy] Address `clippy::missing_transmute_annotations` in src/trans…
DanielEScherzer d10b756
[Clippy] Address `clippy::from_over_into` in src/tree.rs
DanielEScherzer 9ff0abd
[Clippy] Address `clippy::manual_unwrap_or` in src/tree.rs
DanielEScherzer df57c81
[Clippy] Address `clippy::missing_safety_doc` in src/util.rs
DanielEScherzer c028158
[Clippy] Address `clippy::needless_lifetimes` in src/util.rs
DanielEScherzer 5721e99
[Clippy] Address `clippy::needless_range_loop` in src/util.rs
DanielEScherzer b987823
[Clippy] Address `clippy::needless_return` in src/util.rs
DanielEScherzer 6a59e5c
[Clippy] Address `clippy::new_without_default` in src/worktree.rs
DanielEScherzer 3aedab1
[Clippy] Address `clippy::redundant_closure` in src/worktree.rs
DanielEScherzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| #![allow(clippy::explicit_auto_deref)] | ||
|
|
||
| use std::ops::{Deref, DerefMut}; | ||
| use std::ptr; | ||
| use std::slice; | ||
|
|
@@ -38,7 +36,7 @@ impl Buf { | |
|
|
||
| /// Attempt to view this buffer as a string slice. | ||
| pub fn as_str(&self) -> Result<&str, Error> { | ||
| str::from_utf8(&**self).map_err(|e| e.into()) | ||
| str::from_utf8(self).map_err(|e| e.into()) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -78,6 +76,7 @@ impl Drop for Buf { | |
| } | ||
|
|
||
| #[test] | ||
| #[allow(clippy::explicit_auto_deref)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot in the last PR. we should use |
||
| fn empty_buf() { | ||
| let mut buf = Buf::new(); | ||
| let x: &[u8] = &*buf; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,3 @@ | ||
| #![allow(clippy::manual_strip)] | ||
| #![allow(clippy::match_result_ok)] | ||
| #![allow(clippy::missing_safety_doc)] | ||
| #![allow(clippy::needless_borrowed_reference)] | ||
| #![allow(clippy::needless_borrows_for_generic_args)] | ||
| #![allow(clippy::should_implement_trait)] | ||
|
|
||
| #[cfg(feature = "cred")] | ||
| use log::{debug, trace}; | ||
| use std::ffi::CString; | ||
|
|
@@ -39,6 +32,7 @@ pub struct CredentialHelper { | |
| impl Cred { | ||
| /// Create a "default" credential usable for Negotiate mechanisms like NTLM | ||
| /// or Kerberos authentication. | ||
| #[expect(clippy::should_implement_trait)] | ||
| pub fn default() -> Result<Cred, Error> { | ||
| crate::init(); | ||
| let mut out = ptr::null_mut(); | ||
|
|
@@ -171,6 +165,11 @@ impl Cred { | |
| } | ||
|
|
||
| /// Unwrap access to the underlying raw pointer, canceling the destructor | ||
| /// | ||
| /// # Safety | ||
| /// | ||
| /// The caller must assume responsibility for freeing the credential if | ||
| /// needed. See the drop implementation for guidance. | ||
| pub unsafe fn unwrap(mut self) -> *mut raw::git_cred { | ||
| mem::replace(&mut self.raw, ptr::null_mut()) | ||
| } | ||
|
|
@@ -277,14 +276,14 @@ impl CredentialHelper { | |
| // Discover `useHttpPath` from `config` | ||
| fn config_use_http_path(&mut self, config: &Config) { | ||
| let mut use_http_path = false; | ||
| if let Some(value) = config.get_bool(&self.exact_key("useHttpPath")).ok() { | ||
| if let Ok(value) = config.get_bool(&self.exact_key("useHttpPath")) { | ||
| use_http_path = value; | ||
| } else if let Some(value) = self | ||
| .url_key("useHttpPath") | ||
| .and_then(|key| config.get_bool(&key).ok()) | ||
| { | ||
| use_http_path = value; | ||
| } else if let Some(value) = config.get_bool("credential.useHttpPath").ok() { | ||
| } else if let Ok(value) = config.get_bool("credential.useHttpPath") { | ||
| use_http_path = value; | ||
| } | ||
|
|
||
|
|
@@ -313,8 +312,8 @@ impl CredentialHelper { | |
| Some(s) => s, | ||
| }; | ||
|
|
||
| if cmd.starts_with('!') { | ||
| self.commands.push(cmd[1..].to_string()); | ||
| if let Some(stripped) = cmd.strip_prefix('!') { | ||
| self.commands.push(stripped.to_string()); | ||
| } else if is_absolute_path(cmd) { | ||
| self.commands.push(cmd.to_string()); | ||
| } else { | ||
|
|
@@ -328,7 +327,7 @@ impl CredentialHelper { | |
|
|
||
| fn url_key(&self, name: &str) -> Option<String> { | ||
| match (&self.host, &self.protocol) { | ||
| (&Some(ref host), &Some(ref protocol)) => { | ||
| (Some(host), Some(protocol)) => { | ||
| Some(format!("credential.{}://{}.{}", protocol, host, name)) | ||
| } | ||
| _ => None, | ||
|
|
@@ -398,7 +397,7 @@ impl CredentialHelper { | |
| c.creation_flags(CREATE_NO_WINDOW); | ||
| } | ||
| c.arg("-c") | ||
| .arg(&format!("{} get", cmd)) | ||
| .arg(format!("{} get", cmd)) | ||
| .stdin(Stdio::piped()) | ||
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::piped()); | ||
|
|
@@ -502,6 +501,7 @@ impl CredentialHelper { | |
|
|
||
| #[cfg(test)] | ||
| #[cfg(feature = "cred")] | ||
| #[allow(clippy::needless_borrows_for_generic_args)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| #[allow(clippy::unused_io_amount)] | ||
| #[allow(clippy::useless_conversion)] | ||
| mod test { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually not fond of this. This may not be useful if we don't really need it. And that was why rust-lang/cargo only turn on a subset of lint group https://github.com/rust-lang/cargo/blob/371a35405026fc16dd9968589f13cd746b96e024/Cargo.toml#L139-L145.
Some of them are too pedantic.