Count lines of code, comments and whitespace in source files/archives by file

cloc_by_file(source, extract_with = NULL)

Arguments

source

file, directory or archive to read from (can be a valid URL)

extract_with

passed into cloc command line. This option is only needed if cloc is unable to figure out how to extract the contents of the input file(s) by itself.

Value

tibble

Note

Unlike it's cloc() counterpart, no percentages are reported by this function

Examples

# whole dir str(cloc_by_file(system.file("extdata", package="cloc")))
#> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 2 obs. of 6 variables: #> $ source : chr "extdata" "extdata" #> $ filename : chr "/Users/bob/packages/cloc/inst/extdata/qrencoder.cpp" "/Users/bob/packages/cloc/inst/extdata/dbi.r" #> $ language : chr "C++" "R" #> $ loc : int 142 138 #> $ blank_lines : int 41 24 #> $ comment_lines: int 63 71
# single file str(cloc_by_file(system.file("extdata", "qrencoder.cpp", package="cloc")))
#> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1 obs. of 6 variables: #> $ source : chr "qrencoder.cpp" #> $ filename : chr "/Users/bob/packages/cloc/inst/extdata/qrencoder.cpp" #> $ language : chr "C++" #> $ loc : int 142 #> $ blank_lines : int 41 #> $ comment_lines: int 63