Skip to content

tcumby/pre-commit-matlab-lint

Repository files navigation

pre-commit-matlab-lint

License Version on GitHub CodeFactor Created with Tyrannosaurus pre-commit Security Status Code Style: Black

A pre-commit hook for validating MATLAB code.

Available Hook

lint-matlab

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=PATH to 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=VERSION to specify a MATLAB version to locate (e.g. "9.10")
  • Use --matlab-release-name=NAME to specify a MATLAB release to locate (e.g. "R2021a")

Other options:

  • Use --treat-warning-as-error to fail on linter warnings, in addition to linter errors.
  • Use --enable-cyclomaticity to enable McCabe cyclomaticity complexity calculation display for each file.
  • Use --enable-modified-cyclomaticity to enable modified cyclomaticity complexity calculation display for each file.
  • Use --ignore-ok-pragmas to ignore %#ok checkcode suppression pragmas in files.
  • Use --checkode-config-file=FILE to specify a settings file. For instructions detail how to create the file, see Save and Reuse Code Analyzer Message Settings.
  • Use --use-default-checkcode-config to ignore any checkcode settings files and use factory defaults.

Usage with pre-commit

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.