R/lines_of_code.R

Defines functions lines_of_code

Documented in lines_of_code

#' LOC calculator
#'
#' @description Calculate the lines of code in a file
#' @param file The file to calculate for - a file-path.
#'
#' @return The list with two entries - the total and the non-empty lines of code.
#' @export
lines_of_code <- function( file )
{
  loaded_file <- readLines(file)

  return( list( total = length(loaded_file),
                nonempty = length(loaded_file) - sum( loaded_file == "" ))
          )
}
JSzitas/qa documentation built on Dec. 18, 2021, 12:28 a.m.