-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 循環的複雑度のテストを追加 * add CI
- Loading branch information
Showing
3 changed files
with
51 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 |
---|---|---|
|
@@ -8,7 +8,12 @@ bin/ojosama: go.* *.go cmd/* internal/* | |
.PHONY: test | ||
test: | ||
go test -cover ./... | ||
which gocyclo && ./scripts/test_cyclomatic_complexity.sh | ||
|
||
.PHONY: install | ||
install: go.* *.go cmd/* internal/* | ||
go install ./cmd/ojosama | ||
|
||
.PHONY: setup-tools | ||
setup-tools: | ||
go install github.com/fzipp/gocyclo/cmd/[email protected] |
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,36 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
err() { | ||
echo "[ERR] $*" >&2 | ||
} | ||
|
||
info() { | ||
echo "[INF] $*" | ||
} | ||
|
||
script_err() { | ||
err "failed the cyclomatic complexity test" | ||
} | ||
|
||
if ! which gocyclo > /dev/null; then | ||
err "please install gocyclo (https://github.com/fzipp/gocyclo)" | ||
script_err | ||
exit 1 | ||
fi | ||
|
||
gocyclo . | awk '21<=$1' > result.txt | ||
err_count="$(wc -l < result.txt)" | ||
if [[ 0 -lt "$err_count" ]]; then | ||
err "the cyclomatic complexity is 21 or higher. please fix those funcitons" | ||
err "---------------------------------------------------------------------" | ||
cat result.txt >&2 | ||
err "---------------------------------------------------------------------" | ||
script_err | ||
rm result.txt | ||
exit 1 | ||
fi | ||
|
||
rm result.txt | ||
info "passed the cyclomatic complexity test" |