Free and open source code quality tools for Octave and MATLAB

MISS_HIT contains more than one tool. This is a quick overview over each tool.

MH Style

A style checker and code formatter

This is the most popular MISS_HIT tool. It can style check your code and auto-fix almost all problems.
function rv= foo (x), if x < 0,,rv=-   x;else,rv=x;,; end;
Running mh_style with the --fix option:
function rv = foo (x)
    if x < 0
        rv = -x;
        rv = x;
There is a rich configuration scheme to fine-tune the rules to how you like them.
Otherwise, the style checker produces a list of problems:
In test_01.m, line 3
| a = [1,2,3,];
|       ^ style: comma cannot be preceeded by whitespace and must be followed by whitespace
You can find more information in the style checker user manual.

MH Metric

A code complexity metrics tool

Industrial code bases often encourage limits on how complex the code is, so that testing and maintenance become easier tasks. There is minimal built-in support for this in mlint using the -cyc option, but it can't easily be automated; embedded MATLAB in Simulink can't be checked easily, and limits cannot be enforced in CI. This, and the need for additional complexity metrics, motivated the creation of MH Metric.
You can configure MH Metric to check your code against some limits:
metric "npath": limit 5
When the tool encounters code that exceeds this limit, you get a complaint:
In function_file.m, line 3
| function function_file
|          ^^^^^^^^^^^^^ metric: exceeded npath: measured 8 > limit 5
MISS_HIT also includes a justification mechanism for metric violations (and any other issue) through special comments you can place in your code:
function function_file
    %| pragma Justify(metric, "npath",
    %|                "there is a great reason why this is OK");
You can also produce reports in a variety of formats:
  • Plain text (good for the command-line)
  • HTML (great for the desktop and digging through the worst-case offenders)
  • JSON (great for integrating the data into your own tools)
You can find more information in the metrics user manual.

MH Lint

A bug-finding tool for MATLAB and Octave

This static analysis tool can find problems in your code. It makes no guarantees to find all problems (it is not sound), nor does it guarantee that any problem found is a real problem (it is not complete either).
This tool is not intended to replace MATLAB mlint. It reports different problems and the key focus is bugs, not style.
For example this condition almost certainly always evaluates to true. But this is not what the user likely intended:
In test.m, line 7
| if x < y < z
|          ^ check (high): chained relation does not work the way you think it does
You can find more information in the lint user manual.

MH Trace

A code/test traceability tool

This tool can be used to extract tracing tags from your tests and write them to an easily parsed JSON file. This is very helpful if you want to demonstrate trequirements traceability (for standards such as ISO 26262).
For example:
classdef PotatoTests < matlab.unittest.TestCase
    methods (Test, TestTags = {'Kittens'})
        function my_test (testCase)
            % test code
Will produce:
    "PotatoTests::my_test": {
        "source": {
            "col_start": 17,
            "filename": "PotatoTests.m",
            "line": 3
        "tags": [
You can find more information in the trace user manual.

MH Copyright

A code maintenance tool

This tool aims assist developers with some common but annoying maintenance tasks relating to copyright notices in large projects. A simple search and replace is often not actually that simple, or changes something in e.g. a string that should not be changed. MH Copyright can perform some of these tasks for you.
For example if you have a copyright notice like this:
% (c) Copyright 2020 Florian Schanda
And you wish to update the year to include the current year, you can use the --update-year action of MH Copyright:
% (c) Copyright 2020-2021 Florian Schanda
This tool can perform a number of tasks, that sometimes occur in large (legacy) projects:
  • Update a copyright notice to the current year
  • Change one copyright holder into something else
  • Merge different copyright holders into one (useful if your company changes name or merges with a different one)
  • Add a notice to files that don't have one yet
You can find more information in the copyright user manual.