Skip to content

Commit a8ace26

Browse files
Fix clippy lints
1 parent 20a9732 commit a8ace26

File tree

4 files changed

+35
-39
lines changed

4 files changed

+35
-39
lines changed

crates/metadata/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub const DEFAULT_TARGETS: &[&str] = &[
7171
#[non_exhaustive]
7272
pub enum MetadataError {
7373
/// The error returned when the manifest could not be read.
74+
#[allow(clippy::upper_case_acronyms)]
7475
#[error("failed to read manifest from disk")]
7576
IO(#[from] io::Error),
7677
/// The error returned when the manifest could not be parsed.

src/repositories/github.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,17 @@ impl RepositoryForge for GitHub {
145145
// When a node is missing (for example if the repository was deleted or made private) the
146146
// GraphQL API will return *both* a `null` instead of the data in the nodes list and a
147147
// `NOT_FOUND` error in the errors list.
148-
for node in response.data.nodes.into_iter() {
149-
if let Some(node) = node {
150-
let repo = Repository {
151-
id: node.id,
152-
name_with_owner: node.name_with_owner,
153-
description: node.description,
154-
last_activity_at: node.pushed_at,
155-
stars: node.stargazer_count,
156-
forks: node.fork_count,
157-
issues: node.issues.total_count,
158-
};
159-
ret.present.insert(repo.id.clone(), repo);
160-
}
148+
for node in response.data.nodes.into_iter().flatten() {
149+
let repo = Repository {
150+
id: node.id,
151+
name_with_owner: node.name_with_owner,
152+
description: node.description,
153+
last_activity_at: node.pushed_at,
154+
stars: node.stargazer_count,
155+
forks: node.fork_count,
156+
issues: node.issues.total_count,
157+
};
158+
ret.present.insert(repo.id.clone(), repo);
161159
}
162160

163161
Ok(ret)

src/repositories/gitlab.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,19 @@ impl RepositoryForge for GitLab {
128128
if !response.errors.is_empty() {
129129
failure::bail!("error updating repositories: {:?}", response.errors);
130130
}
131-
for node in data.projects.nodes.into_iter() {
132-
if let Some(node) = node {
133-
let repo = Repository {
134-
id: node.id,
135-
name_with_owner: node.full_path,
136-
description: node.description,
137-
last_activity_at: node.last_activity_at,
138-
stars: node.star_count,
139-
forks: node.forks_count,
140-
issues: node.open_issues_count.unwrap_or(0),
141-
};
142-
let id = repo.id.clone();
143-
node_ids.remove(&id);
144-
ret.present.insert(id, repo);
145-
}
131+
for node in data.projects.nodes.into_iter().flatten() {
132+
let repo = Repository {
133+
id: node.id,
134+
name_with_owner: node.full_path,
135+
description: node.description,
136+
last_activity_at: node.last_activity_at,
137+
stars: node.star_count,
138+
forks: node.forks_count,
139+
issues: node.open_issues_count.unwrap_or(0),
140+
};
141+
let id = repo.id.clone();
142+
node_ids.remove(&id);
143+
ret.present.insert(id, repo);
146144
}
147145

148146
if ret.present.is_empty() && rate_limit.map(|x| x < 1).unwrap_or(false) {

src/web/crate_details.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,16 @@ impl CrateDetails {
134134
// get releases, sorted by semver
135135
let releases = releases_for_crate(conn, crate_id);
136136

137-
let repository_metadata = if let Some(host) = krate.get::<_, Option<String>>("repo_host") {
138-
Some(RepositoryMetadata {
139-
issues: krate.get("repo_issues"),
140-
stars: krate.get("repo_stars"),
141-
forks: krate.get("repo_forks"),
142-
name: krate.get("repo_name"),
143-
icon: up.get_icon_name(&host),
144-
})
145-
} else {
146-
None
147-
};
137+
let repository_metadata =
138+
krate
139+
.get::<_, Option<String>>("repo_host")
140+
.map(|host| RepositoryMetadata {
141+
issues: krate.get("repo_issues"),
142+
stars: krate.get("repo_stars"),
143+
forks: krate.get("repo_forks"),
144+
name: krate.get("repo_name"),
145+
icon: up.get_icon_name(&host),
146+
});
148147

149148
let metadata = MetaData {
150149
name: krate.get("name"),

0 commit comments

Comments
 (0)