diff --git a/.codespellignorelines b/.codespellignorelines index 4e11e13cf8..460b8f21b0 100644 --- a/.codespellignorelines +++ b/.codespellignorelines @@ -191,3 +191,11 @@ import java.nio.ByteOrder; string("one\\\"two\\\\three\\/four\\bfive\\fsix\\nseven\\reight\\tnine"), s1 = "one\"two\\three/four\bfive\fsix\nseven\reight\tnine"; string("one\\\"two\\\\three\\/four\\bfive\\fsix\\nseven\\reight\\tnine"), + self.assertEqual(rtf._EscapeData(u'caf\xe9'), "caf\\xe9") + self.assertEqual('%s' % rtf._EscapeData(u'caf\xe9'), "caf\\xe9") + self.assertEqual('%s' % rtf._EscapeData(['caf\xe9']), "['caf\\\\xe9']") + self.assertEqual('%s' % rtf._EscapeData({"a": "caf\xe9"}), + "{'a': 'caf\\\\xe9'}") +# self.assertEqual('%s' % rtf._EscapeData({"caf\xe9": "bar"}), +# "{'caf\xe9': 'bar'}") + "forin": true, diff --git a/.codespellignorewords b/.codespellignorewords index b893450e9e..e32d26cb00 100644 --- a/.codespellignorewords +++ b/.codespellignorewords @@ -2,3 +2,4 @@ acn ACN inflight thead +wronly diff --git a/.github/problem-matcher-lint-spellintian.json b/.github/problem-matcher-lint-spellintian.json new file mode 100644 index 0000000000..d53fdd5294 --- /dev/null +++ b/.github/problem-matcher-lint-spellintian.json @@ -0,0 +1,15 @@ +{ + "problemMatcher": [ + { + "owner": "lint-spellintian", + "severity": "warning", + "pattern": [ + { + "regexp": "^([^:]+):(\\s+)(.+)$", + "file": 1, + "message": 3 + } + ] + } + ] +} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c0ac97b39b..33882f0bf4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -194,3 +194,63 @@ jobs: libusb-1.0-0-dev liblo-dev libavahi-client-dev python3-numpy - name: flake8 run: make flake8 VERBOSE=1 + spellintian: + name: spellintian + runs-on: ubuntu-latest + container: debian:stable + needs: build + steps: + - name: Download built source tree archive + uses: actions/download-artifact@v3 + with: + name: ola-debian-stable-built-source-tree + path: . + - name: SHA256 artifact archive + run: sha256sum ola-debian-stable-built-source-tree.tar.gz + - name: Unarchive artifacts and delete archive + shell: bash + run: | + tar -xvzf ola-debian-stable-built-source-tree.tar.gz . + rm ola-debian-stable-built-source-tree.tar.gz + - name: Display structure of extracted files + if: env.ACTIONS_STEP_DEBUG == 'true' + run: ls -alR + - name: Update package database + run: apt-get update -y + - name: Install lint tools + run: apt-get -y install moreutils lintian + - name: Enable Problem Matcher for GitHub annotations + run: echo "::add-matcher::.github/problem-matcher-lint-spellintian.json" + - name: spellintian + run: ./scripts/spelling.sh spellintian + codespell: + name: codespell + runs-on: ubuntu-latest + container: debian:stable + needs: build + steps: + - name: Download built source tree archive + uses: actions/download-artifact@v3 + with: + name: ola-debian-stable-built-source-tree + path: . + - name: SHA256 artifact archive + run: sha256sum ola-debian-stable-built-source-tree.tar.gz + - name: Unarchive artifacts and delete archive + shell: bash + run: | + tar -xvzf ola-debian-stable-built-source-tree.tar.gz . + rm ola-debian-stable-built-source-tree.tar.gz + - name: Display structure of extracted files + if: env.ACTIONS_STEP_DEBUG == 'true' + run: ls -alR + - name: Update package database + run: apt-get update -y + - name: Install lint tools + run: apt-get -y install python3-pip git moreutils + - name: Install Python lint tools + run: python3 -m pip install --no-input git+https://github.com/codespell-project/codespell.git + - name: Setup codespell annotations + uses: codespell-project/codespell-problem-matcher@v1 + - name: codespell + run: ./scripts/spelling.sh codespell diff --git a/common/rdm/testdata/test_pids.proto b/common/rdm/testdata/test_pids.proto index bc0d01487f..2a2e613dcb 100644 --- a/common/rdm/testdata/test_pids.proto +++ b/common/rdm/testdata/test_pids.proto @@ -2263,7 +2263,7 @@ pid { } field { type: STRING - name: "modulation_frequence_description" + name: "modulation_frequency_description" max_size: 32 } } diff --git a/scripts/spelling.sh b/scripts/spelling.sh new file mode 100755 index 0000000000..f1475e95da --- /dev/null +++ b/scripts/spelling.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# spellintian.sh +# Copyright (C) 2023 Perry Naseck, Peter Newman + +# This script is based on Travis CI tests by Peter Newman +current_test="" +if [ "$1" = "spellintian" ]; then + current_test="spellintian" +elif [ "$1" = "codespell" ]; then + current_test="codespell" +else + echo "Unknown test \"$1\" specified in first argument. Options are spellintian and codespell." + exit 1; +fi; + +if ! [ -x "$(command -v zrun)" ]; then + echo "error: Cannot find zrun. Do you need the moreutils package?" + exit 1; +fi; +if [ $current_test = "spellintian" ] && ! [ -x "$(command -v spellintian)" ]; then + echo "error: Cannot find spellintian. Do you need the lintian package?" + exit 1; +fi; +if [ $current_test = "codespell" ] && ! [ -x "$(command -v codespell)" ]; then + echo "error: Cannot find codespell. Install via pip." + exit 1; +fi; + +SPELLINGBLACKLIST=$(cat <<-BLACKLIST + -wholename "./.codespellignorelines" -or \ + -wholename "./.codespellignorewords" -or \ + -wholename "./.git/*" -or \ + -wholename "./Makefile" -or \ + -wholename "./Makefile.in" -or \ + -wholename "./aclocal.m4" -or \ + -wholename "./autom4te.cache/*" -or \ + -wholename "./common/protocol/Ola.pb.*" -or \ + -wholename "./common/rpc/TestService.pb.*" -or \ + -wholename "./config.log" -or \ + -wholename "./config.status" -or \ + -wholename "./config/config.guess" -or \ + -wholename "./config/config.sub" -or \ + -wholename "./config/depcomp" -or \ + -wholename "./config/install-sh" -or \ + -wholename "./config/libtool.m4" -or \ + -wholename "./config/ltmain.sh" -or \ + -wholename "./config/ltoptions.m4" -or \ + -wholename "./config/ltsugar.m4" -or \ + -wholename "./config/missing" -or \ + -wholename "./configure" -or \ + -wholename "./java/Makefile" -or \ + -wholename "./java/Makefile.in" -or \ + -wholename "./libtool" -or \ + -wholename "./olad/www/mobile.js" -or \ + -wholename "./olad/www/new/js/app.min.js" -or \ + -wholename "./olad/www/new/js/app.min.js.map" -or \ + -wholename "./olad/www/new/libs/angular/js/angular.min.js" -or \ + -wholename "./olad/www/new/libs/marked/js/marked.min.js" -or \ + -wholename "./olad/www/ola.js" -or \ + -wholename "./plugins/artnet/messages/ArtNetConfigMessages.pb.*" -or \ + -wholename "./tools/ola_trigger/config.tab.*" -or \ + -wholename "./tools/ola_trigger/lex.yy.cpp" +BLACKLIST +) + +spellingfiles=$(eval "find ./ -type f -and ! \( \ + $SPELLINGBLACKLIST \ + \) | xargs") + +if [ $current_test = "spellintian" ]; then + # count the number of spellintian errors, including duplicate words + # spellintian does not change the exit code, so the output must be checked + spellintian_issues="$(zrun spellintian $spellingfiles 2>&1)" + + if [[ -n $spellintian_issues ]]; then + printf "%s\n" "$spellintian_issues" + # For now we always exit with success, as these errors are manually checked + # TODO: Actively match and skip printing known false positives, exit with + # errors properly. + # exit 1; + exit 0; + fi; +elif [ $current_test = "codespell" ]; then + if ! zrun codespell --interactive 0 --check-filenames --check-hidden \ + --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" \ + --exclude-file .codespellignorelines \ + --ignore-words .codespellignorewords $spellingfiles 2>&1; then + exit 1; + fi; +fi; diff --git a/tools/rdm/TestDefinitions.py b/tools/rdm/TestDefinitions.py index 0f23a783fb..a76c6dbe4e 100644 --- a/tools/rdm/TestDefinitions.py +++ b/tools/rdm/TestDefinitions.py @@ -1520,7 +1520,7 @@ def VerifyResult(self, response, fields): language_set.add(language) if ContainsUnprintable(language): self.AddAdvisory( - 'Language name in languague capabilities contains unprintable ' + 'Language name in language capabilities contains unprintable ' 'characters, was %s' % language.encode('string-escape')) self.SetProperty('languages_capabilities', language_set)