-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfindNonSuppressesOutput.m
36 lines (32 loc) · 1.46 KB
/
findNonSuppressesOutput.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function findNonSuppressedOutput( p, considerPath )
% finds, based on profile data, lines of code which produce non-suppressed output
% (not terminated by semicolon). Useful to find annoying output in large programs
% consisting of many files. Only functions which are actually called are considered.
%
% to use:
% profile on; YourFunct(a,b,c); profile off;
% p=profile('info');
% findNonSuppressedOutput( p, '/code/projectA/' )
%
% this will run mlint on all called functions in path /code/projectA/ (and subdirs)
% and report lines that contain the requested mlint IDs (here: non-terminated lines)
% functions called that reside outside the provided path are ignored.
%
%April 2009, ueli rutishauser, urut@caltech.edu
IDsToCatch = { 'NOPRT', 'NOPTS' }; %list of mlint IDs to find in all functions called
funcTable = p(1).FunctionTable;
n=length(funcTable);
disp('Files that have entries that dont supress output:');
for k=n:-1:1
fName = funcTable(k).FileName;
if ~isempty( strfind( fName, considerPath))
mInfo = mlint( fName, '-id' );
for j=1:length(mInfo) %go through each mlint entry to find wanted ID
if sum(strcmp( mInfo(j).id, IDsToCatch ))>0
lNrStr = num2str(mInfo(j).line);
cmdStr = ['<a href="matlab: opentoline(''' fName ''',' lNrStr ',1)">' lNrStr '</a>'];
disp([cmdStr ' F: ' fName ' M:' mInfo(j).message ]);
end
end
end
end