Package: alidistlint
alidistlint- code linter foralidistrecipesalidistlintrunsshellcheckon the scripts inalidistrecipes andyamllinton their YAML headers, in addition to its own validation and checks on the YAML header and scripts in the recipe.InstallationTo installalidistlint, run:python3-mpipinstall--useralidistlintYou should also installyamllintandshellcheck, though this is optional.If you want to use the--changesflag, install its dependencies like this:python3-mpipinstall--user'alidistlint[git]'UsageRunalidistlint -hto get more information about its arguments.usage: alidistlint [-h] [-S] [-Y] [-H] [-f FORMAT] [-e | --changes COMMITS] RECIPE [RECIPE ...]You can disable individual checkers using-S/--no-shellcheckand-Y/--no-yamllintfor external linters, or-L/--no-scriptlintand-H/--no-headerlintforalidistlint's built-in linters.
By default, all checkers are run.Optionally, select the output format of errors using-f/--format.You can also makealidistlintlimit the warnings and notes it outputs.
Use the-e/--errors-onlyoption to omit them entirely, and only show critical error messages.Alternatively, you can limit non-critical messages to those that apply to changed code between the given commits using the--changesoption.
Errors are always shown, even if they apply to unchanged lines.
This can be useful in CI, to gradually transition to using this linter.Finally, pass one or multiple files to be checked toalidistlint.
You can use-for the standard input here, but be aware that this will produce spurious errors, as file names are meaningful for alidist recipes.Errors and warnings will be printed to standard output in the format you selected.If any messages with "error" severity were produced,alidistlintexits with a non-zero exit code.Shellcheck validationThe main build recipe (after the---line) is passed toshellcheck.Currently, toplevel keys ending in_recipeor_check(such asincremental_recipe) are also checked usingshellcheck.
This does not work for such keys specified inoverridesyet.There is a known issue with the checking of the above keys: if they do not start on a new line (using e.g.key: |), the reported line numbers for shellcheck errors will be off by one.Internal script checksThe following error codes are produced by the internal linter for scripts in recipes.
This linter checks for alidist-specific pitfalls and bad practices in shell scripts that shellcheck won't know about.
It can be switched off using-L/--no-scriptlint.
There is currently no way to disable individual checks.ali:script-type(error):
The contents of a*_recipeor*_checkvalue in the YAML header were not parsed as a string.
Perhaps you used a barefoo_recipe:, which results in anullvalue, not an empty string.ali:missing-modulefile(note):
The linter could not detect the creation of a Modulefile for this package, even though it has determined that one is needed.
Ideally, usealibuild-generate-moduleto create a Modulefile for you.
If you're generating a Modulefile yourself, make sure that it starts with a#%Module1.0comment and that this string appears in the script.ali:consider-a-g-m(note):
The linter detected that you're manually generating a Modulefile in this recipe.
You should prefer usingalibuild-generate-module, which creates the common Modulefile boilerplate for you.
If usingalibuild-generate-module, you can still append your own Modulefile commands to the generated file.ali:bad-shebang(note):aliBuildruns scripts usingbash -e.
Non-trivial scripts (i.e. the "main" script in a recipe andincremental_recipe, if provided) must start with a#!/bin/bash -eline to signal this toshellcheck.
For other scripts, this check is only enforced if the script in question already has a shebang line, to avoid confusion.ali:colons-prepend-path(error):
Modules 4 does not allow colons inprepend-path, but the linter detected that you used them.
Use multipleprepend-pathcalls to prepend multiple things to$PATHinstead.ali:dyld-library-path(note):
On MacOS, theDYLD_LIBRARY_PATHvariable is not propagated to subprocesses if System Integrity Protection is enabled.
Recipes must not rely on this variable.
If there is a problem and libraries cannot be found at runtime, thenaliBuild's relocation code must be fixed.ali:masked-exitcode(note):
Commands of the formmkdir ... && rsync ...are an often-copy-pasted pattern in alidist recipes.
This is usually used to install Modulefiles.
However, this line does not behave correctly if themkdirfails: in that case, thersyncis silently skipped.
If you find a false positive for this check, please open an issue.Internal YAML header validationThe following error codes are produced by the internal linter for YAML headers.
It can be switched off using-H/--no-headerlint.
There is currently no way to disable individual checks.ali:empty(error):
The YAML header was not found.
It must be terminated by a\n-terminated line containing nothing but three dashes (---).ali:parse(error):
The YAML header could not be parsed or was fundamentally invalid.
This is produced when PyYAML'syaml.loadraises an error or when the provided YAML header is not a dictionary.key: valuepairs must be provided as the YAML header.ali:schema(error):
The YAML header did not conform to its schema.
See the error message for more details.ali:key-order(warning):
Thepackage,versionandtagkeys were not found in the correct order.
These keys should be the first in the file, in the above order (if present).
Additionally, therequireskey must come beforebuild_requires.ali:replacement-specs(warning):
Either theprefer_system_checkseems to select a replacement spec, but
none are defined using theprefer_system_replacement_specskey, or
replacement specs are defined, but none are ever selected by theprefer_system_check.GitHub Actions integrationYou can runalidistlintas part of a GitHub Action using-f github. In that case,alidistlintwill annotate files with the errors found in them.alidistlintwill exit with a non-zero exit code if any errors were found (but not if only warnings were produced), which will cause the workflow to fail.Vim integrationPut the following in your.vimrc:autocmdBufNewFile,BufRead*alidist/*.shsetmakeprg=alidistlint\-f\ gcc\ %errorformat=%f:%l:%c:\ %t%*[a-z]:\ %m" If you want to automatically re-run the linter on every save:autocmdBufWritePost*alidist/*.shmakeThen you can use:maketo run the linter,:clto see the error list, and navigate from one error to another using:cp(previous),:cc(current) and:cn(next).Emacs integrationHere is a simple Flycheck checker usingalidistlint.
You can set this to check alidist recipes.(require'flycheck)(flycheck-def-executable-varalidist"alidistlint")(flycheck-define-checkeralidist"A syntax checker and linter for alidist recipes.";; `flycheck-alidist-executable' automatically overrides the car of the;; :command list if set and non-nil.:command("alidistlint""--format=gcc"source):error-patterns((errorline-start(file-name)":"line":"column": error: "(message)" ["(id(minimal-match(one-or-morenot-newline)))"]"line-end)(warningline-start(file-name)":"line":"column": warning: "(message)" ["(id(minimal-match(one-or-morenot-newline)))"]"line-end)(infoline-start(file-name)":"line":"column": note: "(message)" ["(id(minimal-match(one-or-morenot-newline)))"]"line-end)))(add-to-list'flycheck-checkers'alidist)