count lines of code for entire project
55 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Neesha
am 6 Okt. 2014
Kommentiert: Willingo
am 1 Apr. 2022
Hi All,
I am looking into counting source code of lines for entire project. Is there a way to do it? I looked into sloc() somebdy posted but it counts only one file at a time. I want to count for the entire project so soemthign can go into the foler and look for each and every .m file
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 6 Okt. 2014
Neesha - try using David Roberts' FEX submission slocDir which calls the sloc function that you mention above.
2 Kommentare
Willingo
am 1 Apr. 2022
If anyone in the future tries to call all the project file names such as
p = currentProject
fNames = [p.Files.Path]'
Be aware that fNames is a string array, which did not exist at the time of sloc, so you need to reconvert it into a character array. I make no promises that this works for all cases, but I used sloc in this manner
p = currentProject
filePaths = char([p.Files.Path]');
myCount = struct;
count0TF = [];
for i = 1:height(filePaths)
try
n = numel(myCount);
myCount(n+1).count = sloc(filePaths(i,:));
[~,fName] = fileparts(filePaths(i,:));
myCount(n+1).filename = fName;
catch
end
end
myProjectTable = struct2table(myCount)
Weitere Antworten (1)
Demetrio Rodriguez Tereshkin
am 14 Apr. 2016
This is what you are looking for: https://github.com/AlDanial/cloc
0 Kommentare
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!