-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sanity Check To prevent the scenario
Add a check to be called in the verify where we can add adtional sanity checks to ensure the qiality of the project
- Loading branch information
1 parent
3f56eba
commit 27f6d94
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#################################################### | ||
# The purpose of this script is allow us to do sanity | ||
# checks to ensure the quality of the code | ||
#################################################### | ||
|
||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo_error() { | ||
echo "[Sanity Check Fail]: $1" | ||
} | ||
|
||
# Criteria 1: Do not use setupLog.Error(nil, ...) | ||
CRITERIA1_RULE="setupLog\.Error\(nil," | ||
CRITERIA1_MSG="Avoid using 'setupLog.Error(nil, ...)'. Instead, use 'errors.New()' or 'fmt.Errorf()' \ | ||
to ensure logs are created. Using 'nil' for errors can result in silent failures, making bugs harder to detect." | ||
|
||
if grep -r --include="*.go" "$CRITERIA1_RULE" .; then | ||
echo_error "$CRITERIA1_MSG" | ||
exit 1 | ||
fi | ||
|
||
echo "Sanity checks passed with success." | ||
exit 0 |