Created
January 10, 2022 07:30
-
-
Save nikosavola/cfadf3a2d43303f854ac86d12cc9f83a to your computer and use it in GitHub Desktop.
Lint all MATLAB files recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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