Skip to content

Instantly share code, notes, and snippets.

@nikosavola
Created January 10, 2022 07:30
Show Gist options
  • Save nikosavola/cfadf3a2d43303f854ac86d12cc9f83a to your computer and use it in GitHub Desktop.
Save nikosavola/cfadf3a2d43303f854ac86d12cc9f83a to your computer and use it in GitHub Desktop.
Lint all MATLAB files recursively
% This code lints all the .m files under working directory recursively
files = ls("./**/*.m");
files = strsplit(string(files))';
% First gather all errors
msgs = {};
for i = 1:length(files(1:end-1))
msgs{i} = checkcode(files{i},'-string');
if ~isempty(msgs{i})
msgs{i} = append(files{i},':',newline, msgs{i});
end
end
% Then report all at once if there are any
for i = 1:length(files(1:end-1))
if ~isempty(msgs{i})
error(strjoin(msgs,'\n'))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment