Skip to content

Commit

Permalink
Fix a few specific lints from clippy nursery
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 22, 2024
1 parent ffbce58 commit 7869dcd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct ClientSet {

impl ClientSet {
pub fn new() -> Self {
ClientSet {
Self {
clients: HashMap::new(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl RepoChangeset {
associated_pr
.html_url
.as_ref()
.ok_or(anyhow!("pr without an html link!?"))?
.ok_or_else(|| anyhow!("pr without an html link!?"))?
.to_string(),
);

Expand Down Expand Up @@ -154,7 +154,7 @@ impl CommitMetadata {
.next()
.unwrap_or("<empty commit message>")
.to_string();
CommitMetadata {
Self {
headline,
link: commit.html_url.clone(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn find_values_yaml(workspace: String, base: &str, head: &str) -> Result<Vec<Rep
continue;
}

let path = new_file.path().ok_or(anyhow!("failed to get file path"))?;
let path = new_file.path().ok_or_else(|| anyhow!("failed to get file path"))?;
if !path.ends_with("images.yaml") {
continue;
}
Expand Down
9 changes: 6 additions & 3 deletions src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Remote {
pub fn parse(url: &str) -> Result<Self, anyhow::Error> {
let remote_url = Url::parse(url).context("can't parse remote")?;
let path_elements: Vec<&str> = remote_url.path().trim_start_matches('/').split('/').collect();
Ok(Remote {
Ok(Self {
host: remote_url.host().context("remote has no host")?.to_owned(),
port: remote_url.port_or_known_default().context("remote has no port")?,
owner: path_elements[0].to_string(),
Expand All @@ -51,7 +51,10 @@ impl Remote {
}

async fn get_client(&self) -> Result<(SemaphorePermit<'_>, &Arc<Octocrab>), anyhow::Error> {
let client = self.client.as_ref().ok_or(anyhow!("no client attached to remote"))?;
let client = self
.client
.as_ref()
.ok_or_else(|| anyhow!("no client attached to remote"))?;
client.lock().await.context("cannot obtain semaphore for client")
}

Expand Down Expand Up @@ -93,7 +96,7 @@ impl Remote {
.await
.context("failed to get pr commits")?
.last()
.ok_or(anyhow!("PR contains no commits?"))?
.ok_or_else(|| anyhow!("PR contains no commits?"))?
.sha
.clone())
}
Expand Down

0 comments on commit 7869dcd

Please sign in to comment.