Main function of rsonar. Orchestrates static analysis (lintr),
style checking (styler), test coverage measurement (covr) and
packaging best practices (goodpractice), then returns an
rsonar_result object summarizing all results.
Usage
sonar_analyse(
path = ".",
include_lint = TRUE,
include_style = TRUE,
include_coverage = fs::dir_exists(fs::path(path, "tests")),
include_goodpractice = fs::file_exists(fs::path(path, "DESCRIPTION")),
exclude_pattern = "(\\.git|\\.ci|renv|packrat|vendor|node_modules|_snaps)",
lintr_config = NULL,
verbose = TRUE
)Arguments
- path
Path to the R project or package to analyze. Defaults to the current directory.
- include_lint
Logical. Enable lintr static analysis. Default
TRUE.- include_style
Logical. Enable styler style checking. Default
TRUE.- include_coverage
Logical. Enable covr coverage measurement. Default
TRUEif atests/directory exists.- include_goodpractice
Logical. Enable goodpractice checks. Default
TRUEif aDESCRIPTIONfile exists.- exclude_pattern
Regular expression to exclude files. Default
"(\\.git|\\.ci|renv|packrat|vendor|node_modules|_snaps)".- lintr_config
Path to a custom
.lintrfile. IfNULL, rsonar automatically looks for.lintrinpath.- verbose
Logical. Show progress in the console. Default
TRUE.
Value
An object of class rsonar_result containing:
lintList of lintr issues (class
lints)styleData frame of files with style issues
coverageA covr object or
NULLgoodpracticeA goodpractice object or
NULLmetricsData frame of consolidated metrics
debtTechnical debt estimate
pathAnalyzed path
timestampAnalysis date/time
Examples
if (FALSE) { # \dontrun{
# Analyze the current package
res <- sonar_analyse(".")
print(res)
# Analyze without coverage (faster)
res <- sonar_analyse(".", include_coverage = FALSE)
# With a custom .lintr file
res <- sonar_analyse(".", lintr_config = "custom.lintr")
} # }