필터 지우기
필터 지우기

count lines of code for entire project

조회 수: 49 (최근 30일)
Neesha
Neesha 2014년 10월 6일
댓글: Willingo 2022년 4월 1일
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

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 10월 6일
Neesha - try using David Roberts' FEX submission slocDir which calls the sloc function that you mention above.
  댓글 수: 2
Neesha
Neesha 2014년 10월 6일
Ok,this worked. I have tried using slocdir, which did not work for me, but slocDir did. Thanks
Willingo
Willingo 2022년 4월 1일
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)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Demetrio Rodriguez Tereshkin
Demetrio Rodriguez Tereshkin 2016년 4월 14일
This is what you are looking for: https://github.com/AlDanial/cloc

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by