Add clippy and rustfmt checks (#58)

This commit is contained in:
Yong Wen Chua 2018-12-19 01:51:09 +01:00 committed by GitHub
parent b15ce2b24b
commit 9f87c73a51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -27,10 +27,14 @@ before_script:
export PATH=$HOME/.local/bin:$PATH export PATH=$HOME/.local/bin:$PATH
# Remove rust-toolchain override for tests # Remove rust-toolchain override for tests
- rm rust-toolchain - rm rust-toolchain
- rustup component add rustfmt
- rustup component add clippy || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
script: script:
- cargo fmt -- --check
- cargo clippy "${CARGO_FLAGS}" -- -D warnings
- | - |
travis-cargo build -- "${CARGO_FLAGS}" && cargo build "${CARGO_FLAGS}" &&
travis-cargo test -- "${CARGO_FLAGS}" && cargo test "${CARGO_FLAGS}" &&
travis-cargo --only nightly doc -- --no-deps "${CARGO_FLAGS}" travis-cargo --only nightly doc -- --no-deps "${CARGO_FLAGS}"
after_success: after_success:
- test $CARGO_FLAGS = "--all-features" && travis-cargo --only nightly doc-upload - test $CARGO_FLAGS = "--all-features" && travis-cargo --only nightly doc-upload

View File

@ -58,7 +58,7 @@ fn on_response_wrapper(
let result = request.local_cache(|| unreachable!("This should not be executed so late")); let result = request.local_cache(|| unreachable!("This should not be executed so late"));
if let &CorsValidation::Failure = result { if let CorsValidation::Failure = *result {
// Nothing else for us to do // Nothing else for us to do
return Ok(()); return Ok(());
} }
@ -144,7 +144,7 @@ mod tests {
assert!(failed_origins.is_empty()); assert!(failed_origins.is_empty());
CorsOptions { CorsOptions {
allowed_origins: allowed_origins, allowed_origins,
allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(), allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(),
allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]), allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]),
allow_credentials: true, allow_credentials: true,

View File

@ -962,7 +962,7 @@ impl Response {
/// Consumes the CORS, set expose_headers to /// Consumes the CORS, set expose_headers to
/// passed headers and returns changed CORS /// passed headers and returns changed CORS
fn exposed_headers(mut self, headers: &[&str]) -> Self { fn exposed_headers(mut self, headers: &[&str]) -> Self {
self.expose_headers = headers.into_iter().map(|s| s.to_string().into()).collect(); self.expose_headers = headers.iter().map(|s| s.to_string().into()).collect();
self self
} }
@ -983,7 +983,7 @@ impl Response {
/// Consumes the CORS, set allow_headers to /// Consumes the CORS, set allow_headers to
/// passed headers and returns changed CORS /// passed headers and returns changed CORS
fn headers(mut self, headers: &[&str]) -> Self { fn headers(mut self, headers: &[&str]) -> Self {
self.allow_headers = headers.into_iter().map(|s| s.to_string().into()).collect(); self.allow_headers = headers.iter().map(|s| s.to_string().into()).collect();
self self
} }
@ -1624,7 +1624,7 @@ mod tests {
assert!(failed_origins.is_empty()); assert!(failed_origins.is_empty());
CorsOptions { CorsOptions {
allowed_origins: allowed_origins, allowed_origins,
allowed_methods: vec![http::Method::Get] allowed_methods: vec![http::Method::Get]
.into_iter() .into_iter()
.map(From::from) .map(From::from)