priv-kweihmann/multimetric

Lines of code for C-Code

Closed this issue · 2 comments

I tested a couple of c-code files and always got the LoC = 0.

When looking into the code I see, that only the "Token.Text" is used to count for newlines. I do not really get, why some tokens should be excluded while counting LoC.

I tried to fix with
for x in tokens: if str(x[0]) not in MetricBaseLOC._needles: print('I am not in') self._metrics[MetricBaseLOC.METRIC_LOC] += len([y for y in x[1] if y == '\n'])

so added a 'not' in the if-clause and it works for c-code.

However, I am not sure about the meaning of "Token.Text" and if this causes issues for other languages. Can @priv-kweihmann clarify the content of Token.Text and why just these token were considered to count LoC?

The token type is something that is documented here.
The best idea would be to create a language specific fix in a way like done here.

Back then when the implementation was created just using Token.Text showed good results for all languages I tested with.
Still if there's something wrong, please create a PR for a potential fix, as highlighted in #21 I'm not actively working on this code anymore

Part of release 2.0.0