The cloc / metrics tool receives files to be run from the usual .codacyrc file.
I found some issues regarding it and this attempts to resolve them:
when passed a list of files that do not exist, example files: [ "something", "foo" ], then the tool seems to completely ignore them and really just reports info when it really finds files. In general it seems a good approach, but we get a case where if we only pass a list of files that don't exist then the output of the tool is totally empty, which can't be parsed as valid json;
when passing the files and if accidentally we add an empty string then currently it is triggering the analysis of the whole /src anyway. This happens because after the codacyrc is parsed we add the prefix of /src to all files so when it reaches the call to cloc it will find that "path" and analyze everything. Example: files: [ "something", "foo", "" ];
when the files is passed by the codacyrc but the array is empty then we get an emtpy Set of paths, which when passed to the cloc call ends up being and empty string and the cloc tool fails when it is not being given an explicit thing to analyze. Example: files: [ ]
The following cases can be checked by running the cloc tool directly in any repo/directory:
cloc --by-file --skip-uniqueness something foo
0 text files.
0 unique files.
0 files ignored.
2 errors:
Unable to read: something
Unable to read: foo
exit code of the tool is 0;
cloc --by-file --skip-uniqueness
... help / usage of the tool is dumped ...
The cloc / metrics tool receives files to be run from the usual .codacyrc file.
I found some issues regarding it and this attempts to resolve them:
files: [ "something", "foo" ]
, then the tool seems to completely ignore them and really just reports info when it really finds files. In general it seems a good approach, but we get a case where if we only pass a list of files that don't exist then the output of the tool is totally empty, which can't be parsed as valid json;files: [ "something", "foo", "" ]
;files: [ ]
The following cases can be checked by running the cloc tool directly in any repo/directory:
exit code of the tool is 0;
exit code of the tool is 2;