matlab结果显示在命令窗口,matlab - 在Matlab的命令窗口中显示TODO / FIXME报告 - 堆栈内存溢出...

这段代码展示了一个MATLAB脚本,用于检查指定文件夹中的所有M文件,调用checkcode进行代码分析,并自定义了一个customCodeCheck函数来查找'TODO'和'FIXME'注释,提醒用户存在的问题。
摘要由CSDN通过智能技术生成

最后我写我自己的代码检查调用checkcode在指定文件夹中的每个M档。

fld_list = {pwd, 'folder', 'other_folder'};

nProblems = 0;

for iFld = 1:length(fld_list)

% fprintf('Checking %s...\n', fld_list{n});

files = dir(fullfile(fld_list{iFld}, '*.m'));

for f = 1:length(files)

filename = fullfile(fld_list{iFld}, files(f).name);

customCodeCheck(filename); %custom function

% check code analyzer

codeWarnings = checkcode(filename);

if not(isempty(codeWarnings))

fprintf('Problem found in %s\n', files(f).name);

for iData = 1:length(codeWarnings)

nProblems = nProblems + 1;

% print out link to problem

fprintf('line %d: %s\n', ...

filename, ...

codeWarnings(iData).line, codeWarnings(iData).line, ...

codeWarnings(iData).message);

end

end

end

end

您可以向其中添加一个customCodeCheck函数,该函数搜索TODO和FIXME并提醒您它们的存在

function customCodeCheck(filename)

fileContents = fileread(filename);

toDos = strfind(fileContents, 'TODO');

fixMes = strfind(fileContents, 'FIXME');

% do other stuff

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值