Skip to content

Temporarily deny clippy::nursery and fix warnings #1615

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
merged 2 commits into from
Feb 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bin/update-downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod test {
name: "foo",
..Default::default()
}
.create_or_update(&conn, None, user_id)
.create_or_update(conn, None, user_id)
.unwrap();
let version = NewVersion::new(
krate.id,
Expand All @@ -149,7 +149,7 @@ mod test {
0,
)
.unwrap();
let version = version.save(&conn, &[]).unwrap();
let version = version.save(conn, &[]).unwrap();
(krate, version)
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod prelude {

fn redirect(&self, url: String) -> Response {
let mut headers = HashMap::new();
headers.insert("Location".to_string(), vec![url.to_string()]);
headers.insert("Location".to_string(), vec![url]);
Response {
status: (302, "Found"),
headers,
Expand Down
6 changes: 1 addition & 5 deletions src/controllers/user/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ pub fn github_access_token(req: &mut dyn Request) -> CargoResult<Response> {
}

// Fetch the access token from github using the code we just got
let token = req
.app()
.github
.exchange(code.clone())
.map_err(|s| human(&s))?;
let token = req.app().github.exchange(code).map_err(|s| human(&s))?;

let ghuser = github::github::<GithubUser>(req.app(), "/user", &token)?;

Expand Down
4 changes: 2 additions & 2 deletions src/models/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ impl Category {
} = self;
EncodableCategory {
id: slug.clone(),
slug: slug.clone(),
description: description.clone(),
slug,
description,
created_at,
crates_cnt,
category: category.rsplit("::").collect::<Vec<_>>()[0].to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ mod tests {
let readme_text =
"[![Crates.io](https://img.shields.io/crates/v/clap.svg)](https://crates.io/crates/clap)";
let repository = "https://github.com/kbknapp/clap-rs/";
let result = markdown_to_html(readme_text, Some(&repository)).unwrap();
let result = markdown_to_html(readme_text, Some(repository)).unwrap();

assert_eq!(
result,
Expand Down
4 changes: 2 additions & 2 deletions src/s3/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Bucket {
} else {
path
};
let date = Utc::now().to_rfc2822().to_string();
let date = Utc::now().to_rfc2822();
let auth = self.auth("PUT", &date, path, "", content_type);
let url = self.url(path);

Expand All @@ -74,7 +74,7 @@ impl Bucket {
} else {
path
};
let date = Utc::now().to_rfc2822().to_string();
let date = Utc::now().to_rfc2822();
let auth = self.auth("DELETE", &date, path, "", "");
let url = self.url(path);

Expand Down
5 changes: 1 addition & 4 deletions src/tests/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,7 @@ fn update_attributes() {
};
let mut badge_attributes_travis_ci2 = HashMap::new();
badge_attributes_travis_ci2.insert(String::from("repository"), String::from("rust-lang/rust"));
badges.insert(
String::from("travis-ci"),
badge_attributes_travis_ci2.clone(),
);
badges.insert(String::from("travis-ci"), badge_attributes_travis_ci2);
krate.update(&badges);
let current_badges = krate.badges();
assert_eq!(current_badges.len(), 1);
Expand Down
8 changes: 4 additions & 4 deletions src/tests/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn show() {
let url = "/api/v1/categories/foo-bar";

// Return not found if a category doesn't exist
anon.get(&url).assert_not_found();
anon.get(url).assert_not_found();

// Create a category and a subcategory
app.db(|conn| {
Expand All @@ -66,7 +66,7 @@ fn show() {
});

// The category and its subcategories should be in the json
let json: CategoryWithSubcategories = anon.get(&url).good();
let json: CategoryWithSubcategories = anon.get(url).good();
assert_eq!(json.category.category, "Foo Bar");
assert_eq!(json.category.slug, "foo-bar");
assert_eq!(json.category.subcategories.len(), 1);
Expand Down Expand Up @@ -171,10 +171,10 @@ fn category_slugs_returns_all_slugs_in_alphabetical_order() {
let (app, anon) = TestApp::init().empty();
app.db(|conn| {
new_category("Foo", "foo", "For crates that foo")
.create_or_update(&conn)
.create_or_update(conn)
.unwrap();
new_category("Bar", "bar", "For crates that bar")
.create_or_update(&conn)
.create_or_update(conn)
.unwrap();
});

Expand Down
14 changes: 7 additions & 7 deletions src/tests/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,41 @@ fn update_crate() {

let krate = app.db(|conn| {
Keyword::find_or_create_all(conn, &["kw1", "kw2"]).unwrap();
CrateBuilder::new("fookey", user.id).expect_build(&conn)
CrateBuilder::new("fookey", user.id).expect_build(conn)
});

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &[]).unwrap();
Keyword::update_crate(conn, &krate, &[]).unwrap();
});
assert_eq!(cnt("kw1"), 0);
assert_eq!(cnt("kw2"), 0);

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &["kw1"]).unwrap();
Keyword::update_crate(conn, &krate, &["kw1"]).unwrap();
});
assert_eq!(cnt("kw1"), 1);
assert_eq!(cnt("kw2"), 0);

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &["kw2"]).unwrap();
Keyword::update_crate(conn, &krate, &["kw2"]).unwrap();
});
assert_eq!(cnt("kw1"), 0);
assert_eq!(cnt("kw2"), 1);

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &[]).unwrap();
Keyword::update_crate(conn, &krate, &[]).unwrap();
});
assert_eq!(cnt("kw1"), 0);
assert_eq!(cnt("kw2"), 0);

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &["kw1", "kw2"]).unwrap();
Keyword::update_crate(conn, &krate, &["kw1", "kw2"]).unwrap();
});
assert_eq!(cnt("kw1"), 1);
assert_eq!(cnt("kw2"), 1);

app.db(|conn| {
Keyword::update_crate(&conn, &krate, &[]).unwrap();
Keyword::update_crate(conn, &krate, &[]).unwrap();
});
assert_eq!(cnt("kw1"), 0);
assert_eq!(cnt("kw2"), 0);
Expand Down
40 changes: 20 additions & 20 deletions src/tests/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ fn show() {
.keyword("kw1")
.downloads(20)
.recent_downloads(10)
.expect_build(&conn)
.expect_build(conn)
});

let json = anon.show_crate("foo_show");
Expand Down Expand Up @@ -627,7 +627,7 @@ fn new_with_renamed_dependency() {

app.db(|conn| {
// Insert a crate directly into the database so that new-krate can depend on it
CrateBuilder::new("package-name", user.as_model().id).expect_build(&conn);
CrateBuilder::new("package-name", user.as_model().id).expect_build(conn);
});

let dependency = DependencyBuilder::new("package-name").rename("my-name");
Expand Down Expand Up @@ -662,7 +662,7 @@ fn new_krate_with_dependency() {
// The name choice of `foo-dep` is important! It has the property of
// name != canon_crate_name(name) and is a regression test for
// https://github.com/rust-lang/crates.io/issues/651
CrateBuilder::new("foo-dep", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo-dep", user.as_model().id).expect_build(conn);
});

let dependency = DependencyBuilder::new("foo-dep");
Expand All @@ -678,7 +678,7 @@ fn reject_new_krate_with_non_exact_dependency() {
let (app, _, user, token) = TestApp::init().with_token();

app.db(|conn| {
CrateBuilder::new("foo-dep", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo-dep", user.as_model().id).expect_build(conn);
});

// Use non-exact name for the dependency
Expand Down Expand Up @@ -727,7 +727,7 @@ fn new_krate_with_wildcard_dependency() {

app.db(|conn| {
// Insert a crate directly into the database so that new_wild can depend on it
CrateBuilder::new("foo_wild", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo_wild", user.as_model().id).expect_build(conn);
});

let dependency = DependencyBuilder::new("foo_wild").version_req("*");
Expand All @@ -750,7 +750,7 @@ fn new_krate_twice() {

app.db(|conn| {
// Insert a crate directly into the database and then we'll try to publish another version
CrateBuilder::new("foo_twice", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo_twice", user.as_model().id).expect_build(conn);
});

let crate_to_publish = PublishBuilder::new("foo_twice")
Expand All @@ -768,7 +768,7 @@ fn new_krate_wrong_user() {

app.db(|conn| {
// Create the foo_wrong crate with one user
CrateBuilder::new("foo_wrong", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo_wrong", user.as_model().id).expect_build(conn);
});

// Then try to publish with a different user
Expand Down Expand Up @@ -819,7 +819,7 @@ fn new_krate_too_big_but_whitelisted() {
app.db(|conn| {
CrateBuilder::new("foo_whitelist", user.as_model().id)
.max_upload_size(2_000_000)
.expect_build(&conn);
.expect_build(conn);
});

let files = [("foo_whitelist-1.1.0/big", &[b'a'; 2000] as &[_])];
Expand Down Expand Up @@ -875,7 +875,7 @@ fn new_krate_duplicate_version() {
// Insert a crate directly into the database and then we'll try to publish the same version
CrateBuilder::new("foo_dupe", user.as_model().id)
.version("1.0.0")
.expect_build(&conn);
.expect_build(conn);
});

let crate_to_publish = PublishBuilder::new("foo_dupe").version("1.0.0");
Expand All @@ -895,7 +895,7 @@ fn new_crate_similar_name() {
app.db(|conn| {
CrateBuilder::new("Foo_similar", user.as_model().id)
.version("1.0.0")
.expect_build(&conn);
.expect_build(conn);
});

let crate_to_publish = PublishBuilder::new("foo_similar").version("1.1.0");
Expand All @@ -915,7 +915,7 @@ fn new_crate_similar_name_hyphen() {
app.db(|conn| {
CrateBuilder::new("foo_bar_hyphen", user.as_model().id)
.version("1.0.0")
.expect_build(&conn);
.expect_build(conn);
});

let crate_to_publish = PublishBuilder::new("foo-bar-hyphen").version("1.1.0");
Expand All @@ -935,7 +935,7 @@ fn new_crate_similar_name_underscore() {
app.db(|conn| {
CrateBuilder::new("foo-bar-underscore", user.as_model().id)
.version("1.0.0")
.expect_build(&conn);
.expect_build(conn);
});

let crate_to_publish = PublishBuilder::new("foo_bar_underscore").version("1.1.0");
Expand Down Expand Up @@ -1191,7 +1191,7 @@ fn download() {
app.db(|conn| {
CrateBuilder::new("foo_download", user.id)
.version(VersionBuilder::new("1.0.0"))
.expect_build(&conn);
.expect_build(conn);
});

let assert_dl_count = |name_and_version: &str, query: Option<&str>, count: i32| {
Expand Down Expand Up @@ -1241,7 +1241,7 @@ fn download_nonexistent_version_of_existing_crate_404s() {
let user = user.as_model();

app.db(|conn| {
CrateBuilder::new("foo_bad", user.id).expect_build(&conn);
CrateBuilder::new("foo_bad", user.id).expect_build(conn);
});

anon.get("/api/v1/crates/foo_bad/0.1.0/download")
Expand All @@ -1254,10 +1254,10 @@ fn dependencies() {
let user = user.as_model();

app.db(|conn| {
let c1 = CrateBuilder::new("foo_deps", user.id).expect_build(&conn);
let v = VersionBuilder::new("1.0.0").expect_build(c1.id, &conn);
let c2 = CrateBuilder::new("bar_deps", user.id).expect_build(&conn);
new_dependency(&conn, &v, &c2);
let c1 = CrateBuilder::new("foo_deps", user.id).expect_build(conn);
let v = VersionBuilder::new("1.0.0").expect_build(c1.id, conn);
let c2 = CrateBuilder::new("bar_deps", user.id).expect_build(conn);
new_dependency(conn, &v, &c2);
});

let deps: Deps = anon
Expand All @@ -1283,7 +1283,7 @@ fn following() {
let (app, _, user) = TestApp::init().with_user();

app.db(|conn| {
CrateBuilder::new("foo_following", user.as_model().id).expect_build(&conn);
CrateBuilder::new("foo_following", user.as_model().id).expect_build(conn);
});

let is_following = || -> bool {
Expand Down Expand Up @@ -1487,7 +1487,7 @@ fn publish_after_removing_documentation() {
app.db(|conn| {
CrateBuilder::new("docscrate", user.id)
.version("0.2.0")
.expect_build(&conn);
.expect_build(conn);
});

// Verify that crates start without any documentation so the next assertion can *prove*
Expand Down
4 changes: 2 additions & 2 deletions src/tests/owners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn check_ownership_two_crates() {
let user2 = app.db_new_user("user_bar");
let user2 = user2.as_model();
let krate_not_owned_by_team =
app.db(|conn| CrateBuilder::new("bar", user2.id).expect_build(&conn));
app.db(|conn| CrateBuilder::new("bar", user2.id).expect_build(conn));

let json = anon.search_by_user_id(user2.id);
assert_eq!(json.crates[0].name, krate_not_owned_by_team.name);
Expand Down Expand Up @@ -176,7 +176,7 @@ fn check_ownership_one_crate() {
.create_or_update(conn)
.unwrap();
let krate = CrateBuilder::new("best_crate", user.id).expect_build(conn);
add_team_to_crate(&t, &krate, &user, conn).unwrap();
add_team_to_crate(&t, &krate, user, conn).unwrap();
t
});

Expand Down
Loading