Runs scc on one or more paths with the --by-file flag and returns
one row per source file.
Usage
scc_by_file(
path = ".",
sort = "code",
no_complexity = FALSE,
uloc = TRUE,
dryness = FALSE,
character = FALSE,
percent = FALSE,
size_unit = NULL,
verbose = FALSE,
debug = FALSE,
no_duplicates = FALSE,
binary = FALSE,
gen = FALSE,
no_gen = FALSE,
min = FALSE,
no_min = FALSE,
min_gen = FALSE,
no_min_gen = FALSE,
min_gen_line_length = NULL,
generated_markers = NULL,
include_ext = NULL,
exclude_ext = NULL,
exclude_dir = NULL,
exclude_file = NULL,
not_match = NULL,
count_as = NULL,
remap_all = NULL,
remap_unknown = NULL,
include_symlinks = FALSE,
no_large = FALSE,
large_byte_count = NULL,
large_line_count = NULL,
count_ignore = FALSE,
no_gitignore = FALSE,
no_gitmodule = FALSE,
no_ignore = FALSE,
no_scc_ignore = FALSE,
no_hborder = FALSE,
no_size = FALSE,
cocomo = FALSE,
auto_print_scc = TRUE,
auto_print_cocomo = TRUE,
avg_wage = NULL,
cocomo_project_type = NULL,
eaf = NULL,
overhead = NULL,
currency_symbol = NULL,
sloccount_format = FALSE,
directory_walker_job_workers = NULL,
file_gc_count = NULL,
file_list_queue_size = NULL,
file_process_job_workers = NULL,
file_summary_job_queue_size = NULL
)Arguments
- path
Character vector of file/directory paths to analyse. Defaults to the current working directory (
".").- sort
Column to sort by. One of
"name","files","lines","code","comments","blanks","complexity". Default"code".- no_complexity
Logical. Skip complexity calculation (
-c).- uloc
Logical. Calculate unique lines of code (
-u).- dryness
Logical. Calculate project DRYness; implies
uloc(-a).- character
Logical. Calculate max/mean characters per line (
-m).- percent
Logical. Include percentage values in tabular output (
-p). No effect on the returned tibble.- size_unit
Character. Set size unit for display. One of
"si","binary","mixed", or an"xkcd-*"variant. DefaultNULL(scc default"si").- verbose
Logical. Verbose output (
-v).- debug
Logical. Enable debug output.
- no_duplicates
Logical. Remove duplicate files from stats (
-d).- binary
Logical. Disable binary-file detection.
- gen
Logical. Identify generated files.
- no_gen
Logical. Ignore generated files; implies
gen.- min
Logical. Identify minified files.
- no_min
Logical. Ignore minified files; implies
min.- min_gen
Logical. Identify minified or generated files (
-z).- no_min_gen
Logical. Ignore minified or generated files; implies
min_gen.- min_gen_line_length
Integer. Bytes per average line threshold for minified/generated detection. Default
NULL(scc default255).- generated_markers
Character vector. Strings in the head of a file that mark it as generated. Passed comma-separated. Default
NULL(scc defaults:c("do not edit", "<auto-generated />")).- include_ext
Character vector. Limit to these file extensions (comma-separated in one flag, e.g.
c("go", "java")) (-i).- exclude_ext
Character vector. Ignore these file extensions; overrides
include_ext(-x).- exclude_dir
Character vector. Directories to exclude. Default
NULL(scc defaults:.git,.hg,.svn).- exclude_file
Character vector. Ignore files with matching names (
-n). DefaultNULL(scc defaults: lock files).- not_match
Character vector. Ignore files/directories whose path matches any regex pattern. Each element becomes its own
--not-matchflag (-M).- count_as
Character. Map extensions to languages, e.g.
"jsp:htm,chead:C Header".- remap_all
Character. Inspect every file and remap by string match, e.g.
"-*- C++ -*-:C Header".- remap_unknown
Character. Like
remap_allbut only for unknown-type files.- include_symlinks
Logical. Count symlinked files.
- no_large
Logical. Ignore files exceeding
large_byte_count/large_line_count.- large_byte_count
Integer. Byte threshold for large-file removal. Default
NULL(scc default1000000).- large_line_count
Integer. Line threshold for large-file removal. Default
NULL(scc default40000).- count_ignore
Logical. Count
.gitignore/.ignorefiles.- no_gitignore
Logical. Disable
.gitignorelogic.- no_gitmodule
Logical. Disable
.gitmoduleslogic.- no_ignore
Logical. Disable
.ignorelogic.- no_scc_ignore
Logical. Disable
.sccignorelogic.- no_hborder
Logical. Remove horizontal borders from tabular output. No effect on the returned tibble.
- no_size
Logical. Remove size-calculation line from tabular output. No effect on the returned tibble.
- cocomo
Logical. When
TRUE, also runssccin tabular mode to extract its COCOMO cost / effort estimate and returns a list with both the per-language tibble ($scc) and a COCOMO tibble ($cocomo, columnsmetric,project_type,value). Defaults toFALSE, in which case the per-language tibble is returned directly and the COCOMO-related arguments (avg_wage,cocomo_project_type,eaf,overhead,currency_symbol,sloccount_format) have no effect.- auto_print_scc
Logical. When
TRUE(default) andcocomo = TRUE, prints the per-language tibble to the console as a side effect. Has no effect whencocomo = FALSE(the visible tibble auto-prints under normal R rules).- auto_print_cocomo
Logical. When
TRUE(default) andcocomo = TRUE, prints the COCOMO tibble (or the raw SLOCCount block whensloccount_format = TRUE) to the console as a side effect.- avg_wage
Integer. Average annual wage for COCOMO calculation. Default
NULL(scc default56286).- cocomo_project_type
Character. COCOMO model type:
"organic","semi-detached","embedded", or"custom,a,b,c,d". DefaultNULL(scc default"organic").- eaf
Numeric. Effort adjustment factor for COCOMO. Default
NULL(scc default1).- overhead
Numeric. Corporate overhead multiplier for COCOMO. Default
NULL(scc default2.4).- currency_symbol
Character. Symbol used in COCOMO cost display. Default
NULL(scc default"$").- sloccount_format
Logical. Print SLOCCount-style COCOMO output.
- directory_walker_job_workers
Integer. Workers for directory walking. Default
NULL(scc default8).- file_gc_count
Integer. Files parsed before GC is enabled. Default
NULL(scc default10000).- file_list_queue_size
Integer. Queue size for discovered files. Default
NULL(scc default12).- file_process_job_workers
Integer. Workers for file-stat collection. Default
NULL(scc default12).- file_summary_job_queue_size
Integer. Queue size for processed-file stats. Default
NULL(scc default12).
Value
When cocomo = FALSE (default), a tibble::tibble() with one
row per file. When cocomo = TRUE, a list (returned invisibly) with
two elements: scc (the per-file tibble) and cocomo (the COCOMO
tibble, or NULL when sloccount_format = TRUE).
Per-file tibble columns:
- language
Programming language name.
- filename
File name (basename).
- location
Full file path.
- lines
Total line count (integer).
- code
Lines of code (integer).
- comments
Lines of comments (integer).
- blanks
Blank lines (integer).
- complexity
Cyclomatic complexity score (integer).
- weighted_complexity
Complexity per 100 lines of code, computed as
(complexity / code) * 100(double;0whencode == 0). Matches the formula used bysccfor its per-file weighted complexity.- bytes
File size in bytes (integer).
- uloc
Unique lines of code (integer). Populated by default (
uloc = TRUE); setuloc = FALSEto skip the calculation, in which case the column is0.- dryness
Only present when
dryness = TRUE(defaultFALSE). DRYness ratio for the file, computed locally asuloc / lines(double;0whenlines == 0). Matches the formulasccuses for its tabularDRYness %line, applied per file instead of project-wide. Passingdryness = TRUEauto-promotesuloctoTRUEsince the formula needs it.- generated
TRUEif file is auto-generated (logical).- minified
TRUEif file is minified (logical).