From abb1ffd367f4046d77ac62b0b017b407997bc43b Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Mar 2020 21:53:14 +0100 Subject: Add codesmell statistics to CI --- .travis-ci.sh | 34 +++++++++++++++++++++++++++++++--- .travis.yml | 12 ++++++++++-- midimonster.h | 6 ++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index e9e3df3..763e558 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -21,7 +21,7 @@ if [ "$TASK" = "spellcheck" ]; then fi # Run codespell to find some more - cs_results=$(codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellcheck_files 2>&1) + cs_results=$(codespell --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellcheck_files 2>&1) cs_errors=$(wc -l <<< "$cs_results") if [ "$cs_errors" -ne 0 ]; then printf "Codespell found %s errors:\n\n" "$cs_errors" @@ -31,12 +31,40 @@ if [ "$TASK" = "spellcheck" ]; then printf "Codespell reports no errors\n" fi exit "$result" -elif [ "$TASK" = 'sanitize' ]; then +elif [ "$TASK" = "codesmell" ]; then + result=0 + + if [ -z "$(which lizard)" ]; then + printf "Installing lizard...\n" + pip3 install lizard + fi + + # Run shellcheck for all shell scripts + printf "Running shellcheck...\n" + shell_files="$(find . -type f -iname \*.sh)" + xargs shellcheck -Cnever -s bash <<< "$shell_files" + if [ "$?" -ne "0" ]; then + result=1 + fi + + # Run cloc for some stats + printf "Code statistics:\n\n" + cloc ./ + + # Run lizard for the project + printf "Running lizard for code complexity analysis\n" + lizard ./ + if [ "$?" -ne "0" ]; then + result=1 + fi + + exit "$result" +elif [ "$TASK" = "sanitize" ]; then # Run sanitized compile travis_fold start "make_sanitize" make sanitize; travis_fold end "make_sanitize" -elif [ "$TASK" = 'windows' ]; then +elif [ "$TASK" = "windows" ]; then travis_fold start "make_windows" make windows; make -C backends lua.dll diff --git a/.travis.yml b/.travis.yml index 48b4b71..a5de2f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_script: - export -f travis_fold script: - - "bash -ex .travis-ci.sh" + - "bash .travis-ci.sh" addons: apt: @@ -35,6 +35,8 @@ addons: - *core_build - mingw-w64 packages: &linters + - python3 + - python3-pip - lintian - codespell - shellcheck @@ -92,7 +94,6 @@ jobs: compiler: clang env: - TASK='sanitize' - allow_failures: - os: linux dist: bionic env: TASK='codesmell' @@ -107,6 +108,13 @@ jobs: apt: packages: - *linters + allow_failures: + - os: linux + dist: bionic + env: TASK='codesmell' + - os: linux + dist: bionic + env: TASK='spellcheck' env: global: diff --git a/midimonster.h b/midimonster.h index bad83c7..dc0e255 100644 --- a/midimonster.h +++ b/midimonster.h @@ -234,10 +234,12 @@ MM_API instance* mm_instance_find(char* backend, uint64_t ident); * matching `ident`, a pointer to it is returned. * This API is just a convenience function. The array of channels is * only used for mapping internally, creating and managing your own - * channel store is possible. + * channel store is possible. When returning pointers from a + * backend-local channel store, the returned pointers must stay + * valid over the lifetime of the instance. * For each channel with a non-NULL `impl` field registered using * this function, the backend will receive a call to its channel_free - * function. + * function (if it exists). */ MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); -- cgit v1.2.3