Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'master' into private/asultanov/opt-refactoring
Signed-off-by: Andriy Sultanov <[email protected]>
  • Loading branch information
last-genius authored Jul 8, 2024
commit 76f232dbb20dda85c76bb8962e8593bbb8fc2ff6
22 changes: 22 additions & 0 deletions quality-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ocamlyacc () {
fi
}


unixgetenv () {
N=1
UNIXGETENV=$(git grep -P -r -o --count 'getenv(?!_opt)' -- **/*.ml | wc -l)
Expand All @@ -117,6 +118,26 @@ hashtblfind () {
fi
}

unnecessary-length () {
N=0
local_grep () {
git grep -r -o --count "$1" -- '**/*.ml' | wc -l
}
UNNECESSARY_LENGTH=$(local_grep "List.length.*=+\s*0")
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "0\s*=+\s*List.length")))
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "List.length.*\s>\s*0")))
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "0\s*<\s*List.length")))
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "List.length.*\s<\s*1")))
UNNECESSARY_LENGTH=$((UNNECESSARY_LENGTH+$(local_grep "1\s*>\s*List.length")))
if [ "$UNNECESSARY_LENGTH" -eq "$N" ]; then
echo "OK found $UNNECESSARY_LENGTH unnecessary usages of List.length in OCaml files."
else
echo "ERROR expected $N unnecessary usages of List.length in OCaml files,
got $UNNECESSARY_LENGTH. Use lst =/<> [] or match statements instead." 1>&2
exit 1
fi
}

list-hd
verify-cert
mli-files
Expand All @@ -126,4 +147,5 @@ vtpm-fields
ocamlyacc
unixgetenv
hashtblfind
unnecessary-length

You are viewing a condensed version of this merge commit. You can view the full changes here.