Skip to content

How are lines of code counted? #840

Answered by spenserblack
jtmr05 asked this question in Q&A
Discussion options

You must be logged in to vote

We use tokei for not only detecting languages, but getting lines of code for each language. Tokei identifies not only blank lines, but also comments. So the count you're seeing should be specifically code, excluding blank lines and comments.

https://docs.rs/tokei/12.1.2/tokei/struct.Language.html#structfield.code

for (language_name, language) in languages.iter() {
let mut code = language.code;
let has_children = !language.children.is_empty();
if has_children {
for reports in language.children.values() {
for stats in reports.iter().map(|r| r.stats.summarise()) {
code += stats.code;

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@jtmr05
Comment options

Answer selected by jtmr05
Comment options

You must be logged in to vote
2 replies
@spenserblack
Comment options

@lukehsiao
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants