Skip to content

Commit c88685b

Browse files
chore: sate clippy
1 parent 623e780 commit c88685b

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/lib.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl fmt::Display for GitUrl {
107107
format!(":{}", &self.path)
108108
}
109109
}
110-
_ => (&self.path).to_string(),
110+
_ => self.path.to_string(),
111111
};
112112

113113
let git_url_str = format!("{}{}{}{}{}", scheme_prefix, auth_info, host, port, path);
@@ -211,7 +211,7 @@ impl GitUrl {
211211
let mut fullname: Vec<&str> = Vec::new();
212212

213213
// TODO: Add support for parsing out orgs from these urls
214-
let hosts_w_organization_in_path = vec!["dev.azure.com", "ssh.dev.azure.com"];
214+
let hosts_w_organization_in_path = ["dev.azure.com", "ssh.dev.azure.com"];
215215
//vec!["dev.azure.com", "ssh.dev.azure.com", "visualstudio.com"];
216216

217217
let host_str = if let Some(host) = normalized.host_str() {
@@ -362,7 +362,7 @@ fn normalize_file_path(filepath: &str) -> Result<Url, GitUrlParseError> {
362362
if let Ok(file_url) = normalize_url(&format!("file://{}", filepath)) {
363363
Ok(file_url)
364364
} else {
365-
return Err(GitUrlParseError::FileUrlNormalizeFailedSchemeAdded);
365+
Err(GitUrlParseError::FileUrlNormalizeFailedSchemeAdded)
366366
}
367367
}
368368
}
@@ -463,11 +463,7 @@ fn is_ssh_url(url: &str) -> bool {
463463

464464
// Make sure we provided a username, and not just `@`
465465
let parts: Vec<&str> = url.split('@').collect();
466-
if parts.len() != 2 && !parts[0].is_empty() {
467-
return false;
468-
} else {
469-
return true;
470-
}
466+
return parts.len() == 2 || parts[0].is_empty();
471467
}
472468

473469
// it's an ssh url if we have a domain:path pattern
@@ -481,11 +477,7 @@ fn is_ssh_url(url: &str) -> bool {
481477
// This should also handle if a port is specified
482478
// no port example: ssh://user@domain:path/to/repo.git
483479
// port example: ssh://user@domain:port/path/to/repo.git
484-
if parts.len() != 2 && !parts[0].is_empty() && !parts[1].is_empty() {
485-
return false;
486-
} else {
487-
return true;
488-
}
480+
parts.len() == 2 && parts[0].is_empty() && parts[1].is_empty()
489481
}
490482

491483
#[derive(Error, Debug, PartialEq, Eq)]

tests/normalize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn null_in_input2() {
169169
// From https://github.com/tjtelan/git-url-parse-rs/issues/51
170170
#[test]
171171
fn large_bad_input1() {
172-
let test_url = std::iter::repeat("g@1::::").take(10000).collect::<String>();
172+
let test_url = "g@1::::".repeat(10000);
173173
let normalized = normalize_url(&test_url);
174174

175175
assert!(normalized.is_err());
@@ -178,7 +178,7 @@ fn large_bad_input1() {
178178
// From https://github.com/tjtelan/git-url-parse-rs/issues/51
179179
#[test]
180180
fn large_bad_input2() {
181-
let test_url = std::iter::repeat(":").take(10000).collect::<String>();
181+
let test_url = ":".repeat(10000);
182182
let normalized = normalize_url(&test_url);
183183

184184
assert!(normalized.is_err());

0 commit comments

Comments
 (0)