Ensure no files have trailing whitespace.

This commit is contained in:
Sergio Benitez 2017-03-15 19:26:15 -07:00
parent ca30e5e901
commit 7139941e04
2 changed files with 18 additions and 5 deletions

View File

@ -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<Uuid, &'static str> = {
let mut m = HashMap::new();
@ -32,8 +32,8 @@ lazy_static! {
#[get("/people/<id>")]
fn people(id: UUID) -> Result<String, String> {
// 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))?)

View File

@ -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