A pre-commit hook for validating MATLAB code.
Validate MATLAB files by analyzing them with MATLAB's checkcode function.
In order to use this hook, MATLAB must be installed and registered. There are three ways to specify which MATLAB instance should be used:
- Use
--matlab-home-path=PATHto supply the full path to a MATLAB home directory (e.g. "/Applications/MATLAB_R2021a.app" on macOS, "C:\Program Files\MATLAB\R2021a" on Windows) - Use
--matlab-version=VERSIONto specify a MATLAB version to locate (e.g. "9.10") - Use
--matlab-release-name=NAMEto specify a MATLAB release to locate (e.g. "R2021a")
Other options:
- Use
--treat-warning-as-errorto fail on linter warnings, in addition to linter errors. - Use
--enable-cyclomaticityto enable McCabe cyclomaticity complexity calculation display for each file. - Use
--enable-modified-cyclomaticityto enable modified cyclomaticity complexity calculation display for each file. - Use
--ignore-ok-pragmasto ignore%#okcheckcode suppression pragmas in files. - Use
--checkode-config-file=FILEto specify a settings file. For instructions detail how to create the file, see Save and Reuse Code Analyzer Message Settings. - Use
--use-default-checkcode-configto ignore any checkcode settings files and use factory defaults.
Add this to your .pre-commit-config.yaml
- repo: https://github.com/tcumby/pre-commit-matlab-lint
rev: "" # Use the sha / tag you want to point at
hooks:
- id: lint-matlab
args: ["--matlab_release_name=R2021a"]Licensed under the terms of the MIT License. New issues and pull requests are welcome. Please refer to the contributing guide and security policy. Generated with Tyrannosaurus.