File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,8 @@ repos:
110110 language : system
111111 files : ^resources/.*\.php$
112112 exclude : ^resources/lib/UnityHTTPD\.php$
113+ - id : assert-no-assertTrue
114+ name : Assert `assertTrue` is not used
115+ entry : bash ./test/assert-no-assertTrue.bash
116+ language : system
117+ files : ^test/.*\.php$
Original file line number Diff line number Diff line change 2222 This will enable strict mode and throw an exception rather than returning ` false ` .
2323- ` UnityHTTPD ` 's user-facing error functionality (ex: ` badRequest ` ) should only be called from ` webroot/**/*.php ` .
2424 ` resources/**/*.php ` should throw exceptions instead.
25+ - No code should call ` PHPUnit\Framework\TestCase::assertTrue ` , instead ` assert ` .
26+ ` assert ` is better because it doesn't just say "something is false", it actually shows what is false.
2527
2628This repository will automatically check PRs for linting compliance.
2729
Original file line number Diff line number Diff line change 1+ set -euo pipefail
2+ trap ' s=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
3+ if [[ $# -lt 1 ]]; then
4+ echo " at least one argument required"
5+ exit 1
6+ fi
7+
8+ funcs=(assertTrue)
9+ rc=0
10+ for func in " ${funcs[@]} " ; do
11+ # --color=never because magit git output log doesn't support it
12+ grep_rc=0; grep -H --color=never --line-number -P ' \b' " $func " ' \s*[\(;]' " $@ " || grep_rc=$?
13+ case " $grep_rc " in
14+ 0)
15+ echo " $func () is not allowed! use an exception instead." ; rc=1 ;;
16+ 1)
17+ : ;; # code is good, do nothing
18+ * )
19+ echo " grep failed!" ; rc=1 ;;
20+ esac
21+ done
22+ exit " $rc "
You can’t perform that action at this time.
0 commit comments