Skip to content

Bump rustfmt and clippy on CI #1256

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 20, 2018
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ matrix:
allow_failures:
- rust: nightly
include:
- rust: nightly-2017-12-28
- rust: nightly-2018-02-13
script:
- cargo install --force rustfmt-nightly --vers 0.3.4
- cargo install --force rustfmt-nightly --vers 0.3.6
- cargo fmt -- --write-mode=diff
- cargo install --force clippy --vers 0.0.177
- cargo install --force clippy --vers 0.0.186
- cargo clippy
- rust: stable
script:
Expand Down
10 changes: 4 additions & 6 deletions src/bin/render-readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,11 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
krate_name, version.num
))
};
if manifest.package.readme.is_none() {
return None;
}

let rendered = {
let path = format!(
"{}-{}/{}",
krate_name,
version.num,
manifest.package.readme.unwrap()
krate_name, version.num, manifest.package.readme?
);
let contents = find_file_by_path(&mut entries, Path::new(&path), version, krate_name);
readme_to_html(
Expand All @@ -262,12 +258,14 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
))
};
return Some(rendered);

#[derive(Deserialize)]
struct Package {
readme: Option<String>,
readme_file: Option<String>,
repository: Option<String>,
}

#[derive(Deserialize)]
struct Manifest {
package: Package,
Expand Down
3 changes: 2 additions & 1 deletion src/crate_owner_invitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pub struct EncodableCrateOwnerInvitation {
pub invited_by_username: String,
pub crate_name: String,
pub crate_id: i32,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
}

/// Handles the `GET /me/crate_owner_invitations` route.
Expand Down
6 changes: 4 additions & 2 deletions src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ pub struct Dependency {

#[derive(Debug, QueryableByName)]
pub struct ReverseDependency {
#[diesel(embed)] dependency: Dependency,
#[sql_type = "::diesel::sql_types::Integer"] crate_downloads: i32,
#[diesel(embed)]
dependency: Dependency,
#[sql_type = "::diesel::sql_types::Integer"]
crate_downloads: i32,
#[sql_type = "::diesel::sql_types::Text"]
#[column_name = "crate_name"]
name: String,
Expand Down
3 changes: 2 additions & 1 deletion src/krate/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {

#[derive(Serialize)]
struct R {
#[serde(rename = "crate")] krate: EncodableCrate,
#[serde(rename = "crate")]
krate: EncodableCrate,
versions: Vec<EncodableVersion>,
keywords: Vec<EncodableKeyword>,
categories: Vec<EncodableCategory>,
Expand Down
6 changes: 4 additions & 2 deletions src/krate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ type ByName<'a> = diesel::dsl::Filter<All, WithName<'a>>;
pub struct EncodableCrate {
pub id: String,
pub name: String,
#[serde(with = "::util::rfc3339")] pub updated_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub updated_at: NaiveDateTime,
pub versions: Option<Vec<i32>>,
pub keywords: Option<Vec<String>>,
pub categories: Option<Vec<String>>,
pub badges: Option<Vec<EncodableBadge>>,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
pub downloads: i32,
pub recent_downloads: Option<i64>,
pub max_version: String,
Expand Down
3 changes: 2 additions & 1 deletion src/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ pub fn publish(req: &mut Request) -> CargoResult<Response> {

#[derive(Serialize)]
struct R<'a> {
#[serde(rename = "crate")] krate: EncodableCrate,
#[serde(rename = "crate")]
krate: EncodableCrate,
warnings: Warnings<'a>,
}
Ok(req.json(&R {
Expand Down
3 changes: 2 additions & 1 deletion src/tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ mod version;

#[derive(Deserialize, Debug)]
struct GoodCrate {
#[serde(rename = "crate")] krate: EncodableCrate,
#[serde(rename = "crate")]
krate: EncodableCrate,
warnings: Warnings,
}
#[derive(Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/tests/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ struct VersionsList {
}
#[derive(Deserialize)]
struct CrateResponse {
#[serde(rename = "crate")] krate: EncodableCrate,
#[serde(rename = "crate")]
krate: EncodableCrate,
versions: Vec<EncodableVersion>,
keywords: Vec<EncodableKeyword>,
}
Expand Down
6 changes: 4 additions & 2 deletions src/tests/schema_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ struct FkConstraint {
#[sql_type = "Text"]
#[column_name = "conname"]
name: String,
#[sql_type = "Text"] definition: String,
#[sql_type = "Text"]
definition: String,
}

#[derive(QueryableByName)]
struct TableNameAndConstraint {
#[sql_type = "Text"]
#[column_name = "relname"]
table_name: String,
#[diesel(embed)] constraint: Option<FkConstraint>,
#[diesel(embed)]
constraint: Option<FkConstraint>,
}

fn get_fk_constraint_definitions(column_name: &str) -> Vec<TableNameAndConstraint> {
Expand Down
18 changes: 12 additions & 6 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ use schema::api_tokens;
#[belongs_to(User)]
pub struct ApiToken {
pub id: i32,
#[serde(skip)] pub user_id: i32,
#[serde(skip)] pub token: String,
#[serde(skip)]
pub user_id: i32,
#[serde(skip)]
pub token: String,
pub name: String,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339::option")] pub last_used_at: Option<NaiveDateTime>,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339::option")]
pub last_used_at: Option<NaiveDateTime>,
}

/// The serialization format for the `ApiToken` model with its token value.
Expand All @@ -32,8 +36,10 @@ pub struct EncodableApiTokenWithToken {
pub id: i32,
pub name: String,
pub token: String,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339::option")] pub last_used_at: Option<NaiveDateTime>,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339::option")]
pub last_used_at: Option<NaiveDateTime>,
}

impl ApiToken {
Expand Down
9 changes: 6 additions & 3 deletions src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ pub struct NewVersion {
#[derive(Serialize, Deserialize, Debug)]
pub struct EncodableVersion {
pub id: i32,
#[serde(rename = "crate")] pub krate: String,
#[serde(rename = "crate")]
pub krate: String,
pub num: String,
pub dl_path: String,
pub readme_path: String,
#[serde(with = "::util::rfc3339")] pub updated_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub updated_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
pub downloads: i32,
pub features: HashMap<String, Vec<String>>,
pub yanked: bool,
Expand Down
9 changes: 6 additions & 3 deletions src/views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ pub struct EncodableCategory {
pub category: String,
pub slug: String,
pub description: String,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
pub crates_cnt: i32,
}

Expand All @@ -21,7 +22,8 @@ pub struct EncodableCategoryWithSubcategories {
pub category: String,
pub slug: String,
pub description: String,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
pub crates_cnt: i32,
pub subcategories: Vec<EncodableCategory>,
}
Expand All @@ -34,7 +36,8 @@ pub use download::EncodableVersionDownload;
pub struct EncodableKeyword {
pub id: String,
pub keyword: String,
#[serde(with = "::util::rfc3339")] pub created_at: NaiveDateTime,
#[serde(with = "::util::rfc3339")]
pub created_at: NaiveDateTime,
pub crates_cnt: i32,
}

Expand Down
6 changes: 4 additions & 2 deletions src/with_count.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[derive(QueryableByName)]
pub struct WithCount<T> {
#[sql_type = "::diesel::sql_types::BigInt"] total: i64,
#[diesel(embed)] record: T,
#[sql_type = "::diesel::sql_types::BigInt"]
total: i64,
#[diesel(embed)]
record: T,
}

pub trait WithCountExtension<T> {
Expand Down