Skip to contents

Runs scc on one or more paths and returns a per-language summary.

Usage

scc(
  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. Default NULL (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 default 255).

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). Default NULL (scc defaults: lock files).

not_match

Character vector. Ignore files/directories whose path matches any regex pattern. Each element becomes its own --not-match flag (-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_all but only for unknown-type files.

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 default 1000000).

large_line_count

Integer. Line threshold for large-file removal. Default NULL (scc default 40000).

count_ignore

Logical. Count .gitignore / .ignore files.

no_gitignore

Logical. Disable .gitignore logic.

no_gitmodule

Logical. Disable .gitmodules logic.

no_ignore

Logical. Disable .ignore logic.

no_scc_ignore

Logical. Disable .sccignore logic.

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 runs scc in 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, columns metric, project_type, value). Defaults to FALSE, 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) and cocomo = TRUE, prints the per-language tibble to the console as a side effect. Has no effect when cocomo = FALSE (the visible tibble auto-prints under normal R rules).

auto_print_cocomo

Logical. When TRUE (default) and cocomo = TRUE, prints the COCOMO tibble (or the raw SLOCCount block when sloccount_format = TRUE) to the console as a side effect.

avg_wage

Integer. Average annual wage for COCOMO calculation. Default NULL (scc default 56286).

cocomo_project_type

Character. COCOMO model type: "organic", "semi-detached", "embedded", or "custom,a,b,c,d". Default NULL (scc default "organic").

eaf

Numeric. Effort adjustment factor for COCOMO. Default NULL (scc default 1).

overhead

Numeric. Corporate overhead multiplier for COCOMO. Default NULL (scc default 2.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 default 8).

file_gc_count

Integer. Files parsed before GC is enabled. Default NULL (scc default 10000).

file_list_queue_size

Integer. Queue size for discovered files. Default NULL (scc default 12).

file_process_job_workers

Integer. Workers for file-stat collection. Default NULL (scc default 12).

file_summary_job_queue_size

Integer. Queue size for processed-file stats. Default NULL (scc default 12).

Value

When cocomo = FALSE (default), a tibble::tibble() with one row per language. When cocomo = TRUE, a list (returned invisibly) with two elements: scc (the per-language tibble) and cocomo (the COCOMO tibble, or NULL when sloccount_format = TRUE).

Per-language tibble columns:

language

Programming language name.

files

Number of files (integer).

lines

Total line count (integer).

code

Lines of code (integer).

comments

Lines of comments (integer).

blanks

Blank lines (integer).

complexity

Total cyclomatic complexity score (integer).

weighted_complexity

Complexity per 100 lines of code, computed as (complexity / code) * 100 (double; 0 when code == 0). Matches the formula used by scc for its per-record weighted complexity.

bytes

File size in bytes (integer).

uloc

Unique lines of code (integer). Populated by default (uloc = TRUE); set uloc = FALSE to skip the calculation, in which case the column is 0.

dryness

Only present when dryness = TRUE (default FALSE). DRYness ratio for the row, computed locally as uloc / lines (double; 0 when lines == 0). Matches the formula scc uses for its tabular DRYness % line, applied per language instead of project-wide. Passing dryness = TRUE auto-promotes uloc to TRUE since the formula needs it.

Examples

if (FALSE) { # \dontrun{
scc()
scc("~/myproject", sort = "lines", no_complexity = TRUE)
scc(".", uloc = TRUE, exclude_dir = c("tests", "vignettes"))
scc(".", no_gen = TRUE, no_min = TRUE, no_duplicates = TRUE)
} # }