Merge pull request #3471 from kevinclark/3448-fix-unittests

Make test/scripts/custom-checks portable
This commit is contained in:
w0rp 2021-01-14 18:08:44 +00:00 committed by GitHub
commit f398faa8d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 53 deletions

View file

@ -10,6 +10,8 @@ ENV PACKAGES="\
git \ git \
python \ python \
py-pip \ py-pip \
grep \
sed \
" "
RUN apk --update add $PACKAGES && \ RUN apk --update add $PACKAGES && \
rm -rf /var/cache/apk/* /tmp/* /var/tmp/* rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

View file

@ -49,8 +49,8 @@ Notes:
* `astyle` * `astyle`
* `ccls` * `ccls`
* `clang` (`cc`) * `clang` (`cc`)
* `clangd`
* `clang-format` * `clang-format`
* `clangd`
* `clangtidy`!! * `clangtidy`!!
* `cppcheck` * `cppcheck`
* `cpplint`!! * `cpplint`!!
@ -67,9 +67,9 @@ Notes:
* `astyle` * `astyle`
* `ccls` * `ccls`
* `clang` (`cc`) * `clang` (`cc`)
* `clang-format`
* `clangcheck`!! * `clangcheck`!!
* `clangd` * `clangd`
* `clang-format`
* `clangtidy`!! * `clangtidy`!!
* `clazy`!! * `clazy`!!
* `cppcheck` * `cppcheck`
@ -140,9 +140,9 @@ Notes:
* `erubis` * `erubis`
* `ruumba` * `ruumba`
* Erlang * Erlang
* `SyntaxErl`
* `elvis`!! * `elvis`!!
* `erlc` * `erlc`
* `SyntaxErl`
* Fish * Fish
* `fish` (-n flag) * `fish` (-n flag)
* Fortran * Fortran
@ -160,17 +160,17 @@ Notes:
* Go * Go
* `bingo` * `bingo`
* `go build`!! * `go build`!!
* `go mod`!!
* `go vet`!!
* `gofmt` * `gofmt`
* `goimports` * `goimports`
* `golangci-lint`!! * `golangci-lint`!!
* `golangserver` * `golangserver`
* `golint` * `golint`
* `gometalinter`!! * `gometalinter`!!
* `go mod`!!
* `gopls` * `gopls`
* `gosimple`!! * `gosimple`!!
* `gotype`!! * `gotype`!!
* `go vet`!!
* `revive`!! * `revive`!!
* `staticcheck`!! * `staticcheck`!!
* GraphQL * GraphQL
@ -203,10 +203,10 @@ Notes:
* HCL * HCL
* `terraform-fmt` * `terraform-fmt`
* HTML * HTML
* `HTMLHint`
* `alex`!! * `alex`!!
* `fecs` * `fecs`
* `html-beautify` * `html-beautify`
* `HTMLHint`
* `prettier` * `prettier`
* `proselint` * `proselint`
* `tidy` * `tidy`
@ -220,12 +220,12 @@ Notes:
* ISPC * ISPC
* `ispc`!! * `ispc`!!
* Java * Java
* `PMD`
* `checkstyle` * `checkstyle`
* `eclipselsp` * `eclipselsp`
* `google-java-format` * `google-java-format`
* `javac` * `javac`
* `javalsp` * `javalsp`
* `PMD`
* `uncrustify` * `uncrustify`
* JavaScript * JavaScript
* `eslint` * `eslint`
@ -332,10 +332,10 @@ Notes:
* `intelephense` * `intelephense`
* `langserver` * `langserver`
* `phan` * `phan`
* `php -l`
* `php-cs-fixer`
* `phpcbf` * `phpcbf`
* `phpcs` * `phpcs`
* `php-cs-fixer`
* `php -l`
* `phpmd` * `phpmd`
* `phpstan` * `phpstan`
* `psalm`!! * `psalm`!!
@ -396,6 +396,8 @@ Notes:
* `styler` * `styler`
* Racket * Racket
* `raco` * `raco`
* Re:VIEW
* `redpen`
* ReasonML * ReasonML
* `merlin` * `merlin`
* `ols` * `ols`
@ -409,8 +411,6 @@ Notes:
* `textlint` * `textlint`
* `vale` * `vale`
* `write-good` * `write-good`
* Re:VIEW
* `redpen`
* RPM spec * RPM spec
* `rpmlint` * `rpmlint`
* Ruby * Ruby
@ -457,10 +457,10 @@ Notes:
* `solium` * `solium`
* SQL * SQL
* `pgformatter` * `pgformatter`
* `sql-lint`
* `sqlfmt` * `sqlfmt`
* `sqlformat` * `sqlformat`
* `sqlint` * `sqlint`
* `sql-lint`
* Stylus * Stylus
* `stylelint` * `stylelint`
* SugarSS * SugarSS

View file

@ -2991,11 +2991,11 @@ documented in additional help files.
hdl-checker...........................|ale-vhdl-hdl-checker| hdl-checker...........................|ale-vhdl-hdl-checker|
vcom..................................|ale-vhdl-vcom| vcom..................................|ale-vhdl-vcom|
xvhdl.................................|ale-vhdl-xvhdl| xvhdl.................................|ale-vhdl-xvhdl|
vim help................................|ale-vim-help-options|
write-good............................|ale-vim-help-write-good|
vim.....................................|ale-vim-options| vim.....................................|ale-vim-options|
vimls.................................|ale-vim-vimls| vimls.................................|ale-vim-vimls|
vint..................................|ale-vim-vint| vint..................................|ale-vim-vint|
vim help................................|ale-vim-help-options|
write-good............................|ale-vim-help-write-good|
vue.....................................|ale-vue-options| vue.....................................|ale-vue-options|
prettier..............................|ale-vue-prettier| prettier..............................|ale-vue-prettier|
vls...................................|ale-vue-vls| vls...................................|ale-vue-vls|

View file

@ -9,8 +9,8 @@ set -u
# options, or read the output below. # options, or read the output below.
# #
image=w0rp/ale image=akevinclark/ale
current_image_id=f58c7bf8900f current_image_id=8e1802ca34b5
# Used in all test scripts for running the selected Docker image. # Used in all test scripts for running the selected Docker image.
DOCKER_RUN_IMAGE="$image" DOCKER_RUN_IMAGE="$image"

View file

@ -58,8 +58,8 @@ formatting.
* [astyle](http://astyle.sourceforge.net/) * [astyle](http://astyle.sourceforge.net/)
* [ccls](https://github.com/MaskRay/ccls) * [ccls](https://github.com/MaskRay/ccls)
* [clang](http://clang.llvm.org/) * [clang](http://clang.llvm.org/)
* [clangd](https://clang.llvm.org/extra/clangd.html)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
* [clangd](https://clang.llvm.org/extra/clangd.html)
* [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk:
* [cppcheck](http://cppcheck.sourceforge.net) * [cppcheck](http://cppcheck.sourceforge.net)
* [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) * [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint)
@ -76,9 +76,9 @@ formatting.
* [astyle](http://astyle.sourceforge.net/) * [astyle](http://astyle.sourceforge.net/)
* [ccls](https://github.com/MaskRay/ccls) * [ccls](https://github.com/MaskRay/ccls)
* [clang](http://clang.llvm.org/) * [clang](http://clang.llvm.org/)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
* [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk:
* [clangd](https://clang.llvm.org/extra/clangd.html) * [clangd](https://clang.llvm.org/extra/clangd.html)
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
* [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk:
* [clazy](https://github.com/KDE/clazy) :floppy_disk: * [clazy](https://github.com/KDE/clazy) :floppy_disk:
* [cppcheck](http://cppcheck.sourceforge.net) * [cppcheck](http://cppcheck.sourceforge.net)
@ -149,9 +149,9 @@ formatting.
* [erubis](https://github.com/kwatch/erubis) * [erubis](https://github.com/kwatch/erubis)
* [ruumba](https://github.com/ericqweinstein/ruumba) * [ruumba](https://github.com/ericqweinstein/ruumba)
* Erlang * Erlang
* [SyntaxErl](https://github.com/ten0s/syntaxerl)
* [elvis](https://github.com/inaka/elvis) :floppy_disk: * [elvis](https://github.com/inaka/elvis) :floppy_disk:
* [erlc](http://erlang.org/doc/man/erlc.html) * [erlc](http://erlang.org/doc/man/erlc.html)
* [SyntaxErl](https://github.com/ten0s/syntaxerl)
* Fish * Fish
* fish [-n flag](https://linux.die.net/man/1/fish) * fish [-n flag](https://linux.die.net/man/1/fish)
* Fortran * Fortran
@ -169,17 +169,17 @@ formatting.
* Go * Go
* [bingo](https://github.com/saibing/bingo) :warning: * [bingo](https://github.com/saibing/bingo) :warning:
* [go build](https://golang.org/cmd/go/) :warning: :floppy_disk: * [go build](https://golang.org/cmd/go/) :warning: :floppy_disk:
* [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk:
* [go vet](https://golang.org/cmd/vet/) :floppy_disk:
* [gofmt](https://golang.org/cmd/gofmt/) * [gofmt](https://golang.org/cmd/gofmt/)
* [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) :warning: * [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) :warning:
* [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk: * [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk:
* [golangserver](https://github.com/sourcegraph/go-langserver) :warning: * [golangserver](https://github.com/sourcegraph/go-langserver) :warning:
* [golint](https://godoc.org/github.com/golang/lint) * [golint](https://godoc.org/github.com/golang/lint)
* [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk: * [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk:
* [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk:
* [gopls](https://github.com/golang/go/wiki/gopls) :warning: * [gopls](https://github.com/golang/go/wiki/gopls) :warning:
* [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk: * [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk:
* [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk: * [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk:
* [go vet](https://golang.org/cmd/vet/) :floppy_disk:
* [revive](https://github.com/mgechev/revive) :warning: :floppy_disk: * [revive](https://github.com/mgechev/revive) :warning: :floppy_disk:
* [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk: * [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk:
* GraphQL * GraphQL
@ -212,10 +212,10 @@ formatting.
* HCL * HCL
* [terraform-fmt](https://github.com/hashicorp/terraform) * [terraform-fmt](https://github.com/hashicorp/terraform)
* HTML * HTML
* [HTMLHint](http://htmlhint.com/)
* [alex](https://github.com/wooorm/alex) :floppy_disk: * [alex](https://github.com/wooorm/alex) :floppy_disk:
* [fecs](http://fecs.baidu.com/) * [fecs](http://fecs.baidu.com/)
* [html-beautify](https://beautifier.io/) * [html-beautify](https://beautifier.io/)
* [HTMLHint](http://htmlhint.com/)
* [prettier](https://github.com/prettier/prettier) * [prettier](https://github.com/prettier/prettier)
* [proselint](http://proselint.com/) * [proselint](http://proselint.com/)
* [tidy](http://www.html-tidy.org/) * [tidy](http://www.html-tidy.org/)
@ -229,12 +229,12 @@ formatting.
* ISPC * ISPC
* [ispc](https://ispc.github.io/) :floppy_disk: * [ispc](https://ispc.github.io/) :floppy_disk:
* Java * Java
* [PMD](https://pmd.github.io/)
* [checkstyle](http://checkstyle.sourceforge.net) * [checkstyle](http://checkstyle.sourceforge.net)
* [eclipselsp](https://github.com/eclipse/eclipse.jdt.ls) * [eclipselsp](https://github.com/eclipse/eclipse.jdt.ls)
* [google-java-format](https://github.com/google/google-java-format) * [google-java-format](https://github.com/google/google-java-format)
* [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) * [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [javalsp](https://github.com/georgewfraser/vscode-javac) * [javalsp](https://github.com/georgewfraser/vscode-javac)
* [PMD](https://pmd.github.io/)
* [uncrustify](https://github.com/uncrustify/uncrustify) * [uncrustify](https://github.com/uncrustify/uncrustify)
* JavaScript * JavaScript
* [eslint](http://eslint.org/) * [eslint](http://eslint.org/)
@ -341,10 +341,10 @@ formatting.
* [intelephense](https://github.com/bmewburn/intelephense-docs) * [intelephense](https://github.com/bmewburn/intelephense-docs)
* [langserver](https://github.com/felixfbecker/php-language-server) * [langserver](https://github.com/felixfbecker/php-language-server)
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions * [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
* [php -l](https://secure.php.net/)
* [php-cs-fixer](http://cs.sensiolabs.org/)
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) * [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
* [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) * [phpcs](https://github.com/squizlabs/PHP_CodeSniffer)
* [php-cs-fixer](http://cs.sensiolabs.org/)
* [php -l](https://secure.php.net/)
* [phpmd](https://phpmd.org) * [phpmd](https://phpmd.org)
* [phpstan](https://github.com/phpstan/phpstan) * [phpstan](https://github.com/phpstan/phpstan)
* [psalm](https://getpsalm.org) :floppy_disk: * [psalm](https://getpsalm.org) :floppy_disk:
@ -405,6 +405,8 @@ formatting.
* [styler](https://github.com/r-lib/styler) * [styler](https://github.com/r-lib/styler)
* Racket * Racket
* [raco](https://docs.racket-lang.org/raco/) * [raco](https://docs.racket-lang.org/raco/)
* Re:VIEW
* [redpen](http://redpen.cc/)
* ReasonML * ReasonML
* [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions
* [ols](https://github.com/freebroccolo/ocaml-language-server) * [ols](https://github.com/freebroccolo/ocaml-language-server)
@ -418,8 +420,6 @@ formatting.
* [textlint](https://textlint.github.io/) * [textlint](https://textlint.github.io/)
* [vale](https://github.com/ValeLint/vale) * [vale](https://github.com/ValeLint/vale)
* [write-good](https://github.com/btford/write-good) * [write-good](https://github.com/btford/write-good)
* Re:VIEW
* [redpen](http://redpen.cc/)
* RPM spec * RPM spec
* [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`)
* Ruby * Ruby
@ -466,10 +466,10 @@ formatting.
* [solium](https://github.com/duaraghav8/Solium) * [solium](https://github.com/duaraghav8/Solium)
* SQL * SQL
* [pgformatter](https://github.com/darold/pgFormatter) * [pgformatter](https://github.com/darold/pgFormatter)
* [sql-lint](https://github.com/joereynolds/sql-lint)
* [sqlfmt](https://github.com/jackc/sqlfmt) * [sqlfmt](https://github.com/jackc/sqlfmt)
* [sqlformat](https://github.com/andialbrecht/sqlparse) * [sqlformat](https://github.com/andialbrecht/sqlparse)
* [sqlint](https://github.com/purcell/sqlint) * [sqlint](https://github.com/purcell/sqlint)
* [sql-lint](https://github.com/joereynolds/sql-lint)
* Stylus * Stylus
* [stylelint](https://github.com/stylelint/stylelint) * [stylelint](https://github.com/stylelint/stylelint)
* SugarSS * SugarSS

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d

View file

@ -15,14 +15,13 @@ while read -r; do
if [[ "$REPLY" =~ ^! ]]; then if [[ "$REPLY" =~ ^! ]]; then
language="${REPLY/!/}" language="${REPLY/!/}"
else else
# shellcheck disable=SC2001
echo "$language - $REPLY" echo "$language - $REPLY"
fi fi
done < <( done < <(
grep '^\*\|^ *\*' doc/ale-supported-languages-and-tools.txt \ grep '^\*\|^ *\*' doc/ale-supported-languages-and-tools.txt \
| sed -e '1,2d' \ | sed -e '1,2d' \
| sed 's/^\* */!/' \ | sed 's/^\* */!/' \
| sed 's/^ *\* *\|!!\|\^\|(.*)\|`//g' \ | sed -E 's/^ *\* *|!!|\^|\(.*\)|`//g' \
| sed 's/ *$//' | sed 's/ *$//'
) > "$doc_file" ) > "$doc_file"
@ -30,13 +29,12 @@ while read -r; do
if [[ "$REPLY" =~ ^! ]]; then if [[ "$REPLY" =~ ^! ]]; then
language="${REPLY/!/}" language="${REPLY/!/}"
else else
# shellcheck disable=SC2001
echo "$language - $REPLY" echo "$language - $REPLY"
fi fi
done < <( done < <(
grep '^\*\|^ *\*' supported-tools.md \ grep '^\*\|^ *\*' supported-tools.md \
| sed 's/^\* */!/' \ | sed 's/^\* */!/' \
| sed 's/^ *\* *\|:floppy_disk:\|:warning:\|(.*)\|\[\|\].*\|-n flag//g' \ | sed -E 's/^ *\* *|:floppy_disk:|:warning:|\(.*\)|\[|\].*|-n flag//g' \
| sed 's/ *$//' | sed 's/ *$//'
) > "$readme_file" ) > "$readme_file"

11
test/script/check-tag-alignment Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
exit_code=0
# Documentation tags need to be aligned to the right margin, so look for
# tags which aren't at the right margin.
grep ' \*[^*]\+\*$' doc/ -r \
| awk '{ sep = index($0, ":"); if (length(substr($0, sep + 1 )) < 79) { print } }' \
| grep . && exit_code=1
exit $exit_code

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e
exit_code=0
tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+'
tags="$(mktemp -t tags.XXXXXXXX)"
refs="$(mktemp -t refs.XXXXXXXX)"
# Grep for tags and references, and complain if we find a reference without
# a tag for the reference. Only our tags will be included.
grep --exclude=tags -roh "\\*$tag_regex\\*" doc | sed 's/*//g' | sort -u > "$tags"
grep --exclude=tags -roh "|$tag_regex|" doc | sed 's/|//g' | sort -u > "$refs"
exit_code=0
if ! [[ $(comm -23 $refs $tags | wc -l) -eq 0 ]]; then
exit_code=1
fi
rm "$tags"
rm "$refs"

View file

@ -35,7 +35,7 @@ sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \
> "$toc_file" > "$toc_file"
# Get all of the doc files in a natural sorted order. # Get all of the doc files in a natural sorted order.
doc_files="$(/usr/bin/env ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)" doc_files="$(/usr/bin/env ls -1v doc | grep '^ale-' | sed 's/^/doc\//' | paste -sd ' ' -)"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
grep -h '\*ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \ grep -h '\*ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \

View file

@ -13,7 +13,7 @@ echo 'Custom warnings/errors follow:'
echo echo
set -o pipefail set -o pipefail
docker run -a stdout "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$? docker run "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
set +o pipefail set +o pipefail
echo echo
@ -23,7 +23,10 @@ echo '========================================'
echo 'Duplicate tags follow:' echo 'Duplicate tags follow:'
echo echo
grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d || exit_code=$? set -o pipefail
docker run "${docker_flags[@]}" test/script/check-duplicate-tags . || exit_code=$?
set +o pipefail
echo
echo '========================================' echo '========================================'
echo 'Checking for invalid tag references' echo 'Checking for invalid tag references'
@ -31,14 +34,9 @@ echo '========================================'
echo 'Invalid tag references tags follow:' echo 'Invalid tag references tags follow:'
echo echo
tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+' set -o pipefail
docker run "${docker_flags[@]}" test/script/check-tag-references || exit_code=$?
# Grep for tags and references, and complain if we find a reference without set +o pipefail
# a tag for the reference. Only our tags will be included.
diff -u \
<(grep --exclude=tags -roh "\\*$tag_regex\\*" doc | sort -u | sed 's/*//g') \
<(grep --exclude=tags -roh "|$tag_regex|" doc | sort -u | sed 's/|//g') \
| grep '^+[^+]' && exit_code=1
echo '========================================' echo '========================================'
echo 'diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables' echo 'diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables'
@ -46,7 +44,9 @@ echo '========================================'
echo 'Differences follow:' echo 'Differences follow:'
echo echo
test/script/check-supported-tools-tables || exit_code=$? set -o pipefail
docker run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
set +o pipefail
echo '========================================' echo '========================================'
echo 'Look for badly aligned doc tags' echo 'Look for badly aligned doc tags'
@ -54,18 +54,18 @@ echo '========================================'
echo 'Badly aligned tags follow:' echo 'Badly aligned tags follow:'
echo echo
# Documentation tags need to be aligned to the right margin, so look for set -o pipefail
# tags which aren't at the right margin. docker run "${docker_flags[@]}" test/script/check-tag-alignment || exit_code=$?
grep ' \*[^*]\+\*$' doc/ -r \ set +o pipefail
| awk '{ sep = index($0, ":"); if (length(substr($0, sep + 1 )) < 79) { print } }' \
| grep . && exit_code=1
echo '========================================' echo '========================================'
echo 'Look for table of contents issues' echo 'Look for table of contents issues'
echo '========================================' echo '========================================'
echo echo
test/script/check-toc || exit_code=$? set -o pipefail
docker run "${docker_flags[@]}" test/script/check-toc || exit_code=$?
set +o pipefail
echo '========================================' echo '========================================'
echo 'Check Python code' echo 'Check Python code'

View file

@ -53,17 +53,29 @@ check_errors() {
regex="$1" regex="$1"
message="$2" message="$2"
include_arg='' include_arg=''
exclude_arg=''
if [ $# -gt 2 ]; then if [ $# -gt 2 ]; then
include_arg="--include $3" include_arg="--include $3"
fi fi
if [ $# -gt 3 ]; then
shift
shift
shift
while (( "$#" )); do
exclude_arg="$exclude_arg --exclude $1"
shift
done
fi
for directory in "${directories[@]}"; do for directory in "${directories[@]}"; do
# shellcheck disable=SC2086 # shellcheck disable=SC2086
while read -r; do while read -r; do
RETURN_CODE=1 RETURN_CODE=1
echo "$REPLY $message" echo "$REPLY $message"
done < <(grep -H -n "$regex" $include_arg "$directory"/**/*.vim \ done < <(grep -H -n "$regex" $include_arg $exclude_arg "$directory"/**/*.vim \
| grep -v 'no-custom-checks' \ | grep -v 'no-custom-checks' \
| grep -o '^[^:]\+:[0-9]\+' \ | grep -o '^[^:]\+:[0-9]\+' \
| sed 's:^\./::') | sed 's:^\./::')
@ -92,7 +104,7 @@ if (( FIX_ERRORS )); then
done done
fi fi
# The arguments are: regex, explanation, [filename_filter] # The arguments are: regex, explanation, [filename_filter], [list, of, exclusions]
check_errors \ check_errors \
'^function.*) *$' \ '^function.*) *$' \
'Function without abort keyword (See :help except-compat)' 'Function without abort keyword (See :help except-compat)'
@ -114,7 +126,10 @@ check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false" check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false" check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something" check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*' # Exclusions for grandfathered-in exceptions
exclusions="clojure/clj_kondo.vim elixir/elixir_ls.vim go/golangci_lint.vim swift/swiftformat.vim"
# shellcheck disable=SC2086
check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*' $exclusions
# Checks for improving type checks. # Checks for improving type checks.
check_errors $'\\(==.\\?\\|is\\) type([\'"]\+)' "Use 'is v:t_string' instead" check_errors $'\\(==.\\?\\|is\\) type([\'"]\+)' "Use 'is v:t_string' instead"
check_errors '\(==.\?\|is\) type([0-9]\+)' "Use 'is v:t_number' instead" check_errors '\(==.\?\|is\) type([0-9]\+)' "Use 'is v:t_number' instead"