2019-01-28 18:32:30 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Project nits enforced here
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
source ci/_
|
|
|
|
|
2019-02-09 09:13:35 -08:00
|
|
|
# Logging hygiene: Please don't print from --lib, use the `log` crate instead
|
2019-01-28 18:32:30 -08:00
|
|
|
declare prints=(
|
|
|
|
'print!'
|
|
|
|
'println!'
|
|
|
|
'eprint!'
|
|
|
|
'eprintln!'
|
2019-05-16 08:23:31 -07:00
|
|
|
'dbg!'
|
2019-01-28 18:32:30 -08:00
|
|
|
)
|
|
|
|
|
2019-03-05 13:24:40 -08:00
|
|
|
# Parts of the tree that are expected to be print free
|
|
|
|
declare print_free_tree=(
|
|
|
|
'core/src'
|
2019-05-03 11:01:35 -07:00
|
|
|
'drone/src'
|
|
|
|
'metrics/src'
|
|
|
|
'netutil/src'
|
|
|
|
'runtime/src'
|
2019-06-20 07:43:31 -07:00
|
|
|
'sdk/bpf/rust/rust-utils'
|
2019-05-03 11:01:35 -07:00
|
|
|
'sdk/src'
|
2019-06-20 07:43:31 -07:00
|
|
|
'programs/bpf/rust'
|
2019-05-16 08:23:31 -07:00
|
|
|
'programs/stake_api/src'
|
|
|
|
'programs/stake_program/src'
|
2019-06-20 07:43:31 -07:00
|
|
|
'programs/vote_api/src'
|
|
|
|
'programs/vote_program/src'
|
2019-03-05 13:24:40 -08:00
|
|
|
)
|
|
|
|
|
2019-05-17 18:55:57 -07:00
|
|
|
if _ git --no-pager grep -n --max-depth=0 "${prints[@]/#/-e }" -- "${print_free_tree[@]}"; then
|
2019-01-28 18:32:30 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-02-09 09:13:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
# Code readability: please be explicit about the type instead of using
|
|
|
|
# Default::default()
|
|
|
|
#
|
|
|
|
# Ref: https://github.com/solana-labs/solana/issues/2630
|
2019-05-17 18:55:57 -07:00
|
|
|
if _ git --no-pager grep -n 'Default::default()' -- '*.rs'; then
|
2019-02-09 09:13:35 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-08 12:15:05 -07:00
|
|
|
# Let's keep a .gitignore for every crate, ensure it's got
|
2019-07-12 18:28:42 -07:00
|
|
|
# /target/ and /farf/ in it
|
2019-05-08 12:15:05 -07:00
|
|
|
declare gitignores_ok=true
|
2019-05-17 18:55:57 -07:00
|
|
|
for i in $(git --no-pager ls-files \*/Cargo.toml ); do
|
2019-05-08 12:15:05 -07:00
|
|
|
dir=$(dirname "$i")
|
|
|
|
if [[ ! -f $dir/.gitignore ]]; then
|
|
|
|
echo 'error: nits.sh .gitnore missing for crate '"$dir" >&2
|
|
|
|
gitignores_ok=false
|
2019-07-12 18:28:42 -07:00
|
|
|
else
|
|
|
|
if ! grep -q -e '^/target/$' "$dir"/.gitignore; then
|
2019-05-08 12:15:05 -07:00
|
|
|
echo 'error: nits.sh "/target/" apparently missing from '"$dir"'/.gitignore' >&2
|
|
|
|
gitignores_ok=false
|
2019-07-12 18:28:42 -07:00
|
|
|
fi
|
|
|
|
if ! grep -q -e '^/farf/$' "$dir"/.gitignore ; then
|
|
|
|
echo 'error: nits.sh "/farf/" apparently missing from '"$dir"'/.gitignore' >&2
|
|
|
|
gitignores_ok=false
|
|
|
|
fi
|
2019-05-08 12:15:05 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
"$gitignores_ok"
|