Ensure no files have trailing whitespace.

This commit is contained in:
Sergio Benitez 2017-03-15 19:26:15 -07:00
parent 8e7c77fe21
commit 40c5f28331
2 changed files with 18 additions and 5 deletions

View File

@ -32,8 +32,8 @@ lazy_static! {
#[get("/people/<id>")] #[get("/people/<id>")]
fn people(id: UUID) -> Result<String, String> { fn people(id: UUID) -> Result<String, String> {
// Because UUID implements the Deref trait, we use Deref coercion to // Because UUID implements the Deref trait, we use Deref coercion to convert
// convert rocket_contrib::UUID to uuid::Uuid. // rocket_contrib::UUID to uuid::Uuid.
Ok(PEOPLE.get(&id) Ok(PEOPLE.get(&id)
.map(|person| format!("We found: {}", person)) .map(|person| format!("We found: {}", person))
.ok_or(format!("Person not found for UUID: {}", id))?) .ok_or(format!("Person not found for UUID: {}", id))?)

View File

@ -28,7 +28,7 @@ function check_versions_match() {
done done
} }
# Ensures there are not tabs in any file in the directories $@. # Ensures there are no tabs in any file.
function ensure_tab_free() { function ensure_tab_free() {
local tab=$(printf '\t') local tab=$(printf '\t')
local matches=$(grep -I -R "${tab}" $ROOT_DIR | egrep -v '/target|/.git|LICENSE') local matches=$(grep -I -R "${tab}" $ROOT_DIR | egrep -v '/target|/.git|LICENSE')
@ -39,6 +39,16 @@ function ensure_tab_free() {
fi 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() { function bootstrap_examples() {
for file in ${EXAMPLES_DIR}/*; do for file in ${EXAMPLES_DIR}/*; do
if [ -d "${file}" ]; then if [ -d "${file}" ]; then
@ -65,6 +75,9 @@ check_versions_match "${LIB_DIR}" "${CODEGEN_DIR}" "${CONTRIB_DIR}"
echo ":: Checking for tabs..." echo ":: Checking for tabs..."
ensure_tab_free ensure_tab_free
echo ":: Checking for trailing whitespace..."
ensure_trailing_whitespace_free
echo ":: Updating dependencies..." echo ":: Updating dependencies..."
cargo update cargo update