From 7139941e04ef711d4de9c1469c65cd3040bff4d9 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 15 Mar 2017 19:26:15 -0700 Subject: [PATCH] Ensure no files have trailing whitespace. --- examples/uuid/src/main.rs | 8 ++++---- scripts/test.sh | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/examples/uuid/src/main.rs b/examples/uuid/src/main.rs index 47a4832f..712db9bd 100644 --- a/examples/uuid/src/main.rs +++ b/examples/uuid/src/main.rs @@ -15,8 +15,8 @@ use rocket_contrib::UUID; mod tests; lazy_static! { - // A small people lookup table for the sake of this example. In a real - // application this could be a database lookup. Notice that we use the + // A small people lookup table for the sake of this example. In a real + // application this could be a database lookup. Notice that we use the // uuid::Uuid type here and not the rocket_contrib::UUID type. static ref PEOPLE: HashMap = { let mut m = HashMap::new(); @@ -32,8 +32,8 @@ lazy_static! { #[get("/people/")] fn people(id: UUID) -> Result { - // Because UUID implements the Deref trait, we use Deref coercion to - // convert rocket_contrib::UUID to uuid::Uuid. + // Because UUID implements the Deref trait, we use Deref coercion to convert + // rocket_contrib::UUID to uuid::Uuid. Ok(PEOPLE.get(&id) .map(|person| format!("We found: {}", person)) .ok_or(format!("Person not found for UUID: {}", id))?) diff --git a/scripts/test.sh b/scripts/test.sh index b9de6755..6a9b891b 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -28,7 +28,7 @@ function check_versions_match() { done } -# Ensures there are not tabs in any file in the directories $@. +# Ensures there are no tabs in any file. function ensure_tab_free() { local tab=$(printf '\t') local matches=$(grep -I -R "${tab}" $ROOT_DIR | egrep -v '/target|/.git|LICENSE') @@ -39,6 +39,16 @@ function ensure_tab_free() { fi } +# Ensures there are no files with trailing whitespace. +function ensure_trailing_whitespace_free() { + local matches=$(egrep -I -R " +$" $ROOT_DIR | egrep -v "/target|/.git") + if ! [ -z "${matches}" ]; then + echo "Trailing whitespace was found in the following:" + echo "${matches}" + exit 1 + fi +} + function bootstrap_examples() { for file in ${EXAMPLES_DIR}/*; do if [ -d "${file}" ]; then @@ -65,6 +75,9 @@ check_versions_match "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}" echo ":: Checking for tabs..." ensure_tab_free +echo ":: Checking for trailing whitespace..." +ensure_trailing_whitespace_free + echo ":: Updating dependencies..." cargo update