Running Mlint on an m-file from Python

3 ビュー (過去 30 日間)
Ragnar Hägg
Ragnar Hägg 2017 年 6 月 15 日
コメント済み: Ragnar Hägg 2017 年 6 月 20 日
We have code review on all our code in Gerrit, and can run automatic tests with Jenkins. What I would like to do is to add an automatic mlint check when new Matlab code is checked in. The Jenkins machines does not have Matlab installed.
My thought was to use the mlint.dll together with ctypes in Python, but then I realized that the mlint.dll has 1591 functions, and I'm unsure how to use it to use the mlint checks on a file.
I want a function similar to the mlintmex. Example:
>> str = mlintmex('perfTest.m')
str =
L 3 (C 1): The value assigned to variable 'A' might be unused.
L 4 (C 1): The value assigned to variable 'B' might be unused.
L 5 (C 1-3): Variable 'ops', apparently a structure, is changed but the value seems to be unused.
L 12 (C 9): This statement (and possibly following ones) cannot be reached.
L 53 (C 19-25): The function 'subFunc' might be unused.
L 53 (C 27-35): Input argument 'iteration' might be unused. If this is OK, consider replacing it by ~.
Please help me if you have any suggestions!
PS. I've thought about using mcc to build mlintmex into a binary, but it seems like a very awkward way around the problem.

回答 (1 件)

Nagarjuna Manchineni
Nagarjuna Manchineni 2017 年 6 月 19 日
編集済み: Nagarjuna Manchineni 2017 年 6 月 19 日
It is possible to check the MATLAB code by using 'mlint' or 'checkcode' (recommended) function. You can use MATLAB engine for python/Java to call this function from python/Java. This needs to have MATLAB installed on the system.
See the following link for more information of MATLAB engine:
Also, you can directly call the MATLAB code by running the code from the command prompt or shell:
matlab -nodisplay -nodesktop -r "checkcode('<filename>')"
Also, note that it is not recommended to call 'mlint' from the mlint.dll as this dll has many dependencies internally with other dll's that are registered by installing MATLAB.
Also, this function is not available for compiling into a module/jar/application using MATLAB Compiler/SDK.
  1 件のコメント
Ragnar Hägg
Ragnar Hägg 2017 年 6 月 20 日
My main purpose of trying this is to avoid having to install Matlab on the Jenkins machines. Figuring out which subset of the Matlab DLLs that are required seems like a smaller task, once it is running.
But thanks for the answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by