pkginspectr (development version)
pkginspectr now has a hex logo, shown in the README and on the pkgdown site.
curl is now listed in Suggests: the network tests use it to check for an internet connection, and failed on CI without it.
pkginspectr 0.3.0
New
pkg_functions()returns one row per named function: its file, location, start line, code lines, number of arguments and whether it is exported (viaexport()orexportPattern()). Useful for finding the largest functions or measuring how much of a package is internal.New
pkg_versions()lists every CRAN release of a package with its date, andpkg_history()runspkg_summary()on several releases (spread evenly across the history by default, or the versions you name) to show how a package grew over time.When several packages are analysed, one that fails (a typo, a failed download, an unreadable folder) no longer aborts the rest. It is reported in a single warning and kept as a row of
NAs, sopkg_history()still returns every other release. A single package, or all packages, failing is still an error.Results print a header saying what they contain, e.g.
# pkginspectr: Lines of code, 3 packages (1 failed), matching the titles used bypkg_plot().New “Derived metrics” section in
vignette("pkginspectr")with copy-and-paste recipes for ratios such as test-to-code lines, comment density, share of code inside functions and help pages per export.pkg_plot()shows non-integer values with at most three decimals, so derived metrics such as ratios stay readable.
pkginspectr 0.2.0
Lifecycle changes
-
All exported functions now share the
pkg_prefix and are named after what they return. The old names still work but are deprecated:
Changes to results
pkg_lines()returns non-overlapping columns.code_lines,comment_lines,roxygen_linesandblank_linesadd up tototal_lines, and so dor_lines,test_linesandother_lines.function_linesnow counts only code lines inside functions. The deprecatedget_code_stats()keeps its original columns.pkg_structure():num_r_files,num_function_r_filesandnum_non_function_r_filesnow count only scripts inR/(previously test anddata-raw/scripts were included).Lines are now classified with R’s parser (
utils::getParseData()) instead of regular expressions and brace counting. Functions assigned with=,\(x)lambdas and anonymous functions are counted; one-line functions no longer absorb the following line;{,}and#inside strings are no longer miscounted. Files that fail to parse produce a warning.Only files that
R CMD buildwould ship are counted:.Rbuildignore, version-control folders and R’s built-in exclusions are respected, so local folders and CRAN tarballs are comparable. Use the newinclude_ignored = TRUEargument to count.Rbuildignored files again.Lower-case
.rfiles,.Rnwvignettes and.rds/.csv/.tsv/.tab/.txtdata files are now recognised.
New features
-
Clearer package sources in
path:- Explicit prefixes
local::,github::andcran::. Unprefixed input still works, but a path that does not exist (e.g."./mypkg") is now an error instead of a GitHub request. - GitHub refs (
"r-lib/cli@v3.6.0"), subfolders ("github::owner/repo/subdir") and browser URLs (github.com/owner/repo/tree/<ref>/<subdir>). - Older CRAN releases (
"cran::desc@1.4.0") and archived CRAN packages.
- Explicit prefixes
New
cacheargument ("session","persistent"or"none"). The persistent cache keeps fixed versions (CRAN releases, GitHub commit SHAs and version tags) across R sessions; GitHub branches are always fetched fresh.pkg_summary()returnspkg_structure()andpkg_lines()in one table, resolving and downloading each package only once.plot()works on any pkginspectr result.pkg_plot()documents all its styling arguments (text_col,bar_col,bg_col,glyph,start,end,max_bars,title), and both views accept the same set. Metric bars are scaled to each metric’s largest value, so packages are easy to compare. The package view groups metrics into “Files” (shares ofnum_files) and “Lines” (shares oftotal_lines), and showsnum_dirswithout a misleading percentage. Default titles describe the data.pkg_structure(),pkg_lines()andpkg_summary()gainquiet = TRUEto suppress progress messages.New
pkginspectr_example()returns the path to a small example package bundled with pkginspectr, so examples run offline.New “Get started” vignette:
vignette("pkginspectr").
Bug fixes
GitHub downloads no longer use the GitHub API, so they are no longer limited to 60 requests per hour.
CRAN downloads work when no CRAN mirror is set (e.g. under
Rscript), and no longer miss packages that need a newer R version.Cached downloads are keyed by owner, repository and ref, so same-named repos from different owners no longer collide, and a failed download no longer leaves a broken cache entry behind.
Files are classified by their path relative to the package root. Previously a package stored under a folder named
tests/,man/ordata/had all of its files misclassified.pkg_cache_clear()returns the cleared path (orNULL) invisibly, as documented, and its message no longer lists both cache types when called without arguments.GitHub and CRAN lookups no longer fail when the suggested glue package is not installed; glue is no longer used.
pkginspectr 0.1.0
-
Added
inspect_package()which returns key statistics about an R package. In particular:-
package: package name -
version: version number -
num_files: number of files in the package -
num_dirs: number of directories in the package -
num_r_files: number of R files in the package -
num_function_r_files: number of R files containing functions -
num_non_function_r_files: number of R files not containing functions -
num_test_files: number of test files in the package -
num_vignettes: number of vignettes in the package -
num_docs: number of documentation files in the package -
num_data_files: number of data files in the package
-
-
Added
get_code_stats()which returns code statistics for an R package. In particular:-
package: package name -
version: version number -
total_lines: total number of lines of code -
blank_lines: total number of blank lines -
comment_lines: total number of comment lines -
roxygen_lines: total number of roxygen lines -
function_lines: total number of lines within functions -
test_lines: total number of lines within test files
-
-
Added
plot_pkg()which plots output frominspect_package()orget_code_stats()in the console. Users can modify colours and shapes of the plot to make it uniquely theirs. It offers two modestype = "package"andtype = "metric":type = "package"plots package statistics for multiple packages grouped by package name.type = "metric"plots package statistics grouped by metric.
-
pkginspectrretrieves package information from- local packages
- CRAN, and
- GitHub repositories.
Updated
README.mdwith examples of how to use the package.Added tests for all functions using
testthat.Create informative
README.md.
