C and C Headers have some unsafe code
kbknapp opened this issue · 8 comments
kbknapp commented
Since the unsafe counter is naive and counts all C and C++ as unsafe it's strange that some code in .c
and .h
files is not unsafe. See the example in the README.md
...
Vinatorul commented
May be some problem with blank lines? Can you add examples ro repo?
kbknapp commented
I noticed it in the Rust repo (See the example output), but I haven't yet done any real investigating such as creating a quick .c
file and seeing what happens.
Vinatorul commented
It seems to be the same bug as #2.
int test() {
return /* test */ 0;
}
Result is
Language Files Lines Blanks Comments Code Unsafe (%)
-------- ----- ----- ------ -------- ---- ----------
C Header 1 3 0 1 2 1 (50.00%)
TOML 1 4 0 0 4
-------- ----- ----- ------ -------- ---- ----------
Totals: 2 7 0 1 6 1 (16.67%)
kbknapp commented
Makes sense, and now I see why I didn't catch it before! Thanks! 😄
Vinatorul commented
The only place, where count.code increments before unsafe check is
else if line.contains(ms) {
debugln!("line contains a multi start");
count.code += 1;
is_in_comments = line.contains(count.multi_end().unwrap());
debugln!("line also contained a multi end: {:?}", is_in_comments);
continue;
}
and there is continue
Vinatorul commented
Let me fix it?
kbknapp commented
That was it! Sorry, I just pushed the patch!