最后我写我自己的代码检查调用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