Lint a single R file.
Description
Runs every registered per-file linter against path, converts the
resulting lintr::Lint objects to scilintr_finding records, and
applies the ANALYSIS_OK[...] waiver filter.
Usage
lint_file(path, config = NULL)
lint_file(path, config = NULL)
Arguments
path |
Path to a .R file.
|
config |
Optional configuration list (loaded from .scilintr.yml).
|
Value
A list of scilintr_finding records.
Examples
# Lint a tiny self-contained file in the session temp directory.
tmp <- tempfile(fileext = ".R")
writeLines("x <- 1", tmp)
findings <- lint_file(tmp)
length(findings)
unlink(tmp)
tmp <- tempfile(fileext = ".R")
writeLines("x <- 1", tmp)
findings <- lint_file(tmp)
length(findings)
unlink(tmp)
Lint an entire project directory.
Description
Walks every .R file, runs the per-file linters, then builds the
project index and runs the cross-file rules against it.
Usage
lint_project(root = ".", config = NULL)
lint_project(root = ".", config = NULL)
Arguments
root |
Project root directory.
|
config |
Optional configuration list.
|
Value
A list of scilintr_finding records aggregated across files.
Examples
# Build a throwaway one-file project inside the session temp directory.
proj <- file.path(tempdir(), "scilintr-demo")
dir.create(proj, showWarnings = FALSE)
writeLines("y <- 2", file.path(proj, "analysis.R"))
findings <- lint_project(proj)
length(findings)
unlink(proj, recursive = TRUE)
proj <- file.path(tempdir(), "scilintr-demo")
dir.create(proj, showWarnings = FALSE)
writeLines("y <- 2", file.path(proj, "analysis.R"))
findings <- lint_project(proj)
length(findings)
unlink(proj, recursive = TRUE)
Main CLI entry point.
Description
Invoked from inst/bin/scilintr or
Rscript -e 'scilintr::main()'.
Usage
main(args = commandArgs(trailingOnly = TRUE))
main(args = commandArgs(trailingOnly = TRUE))
Arguments
args |
Character vector of command-line arguments.
|
Value
Invisibly returns 0L when no findings are reported and 1L
otherwise. Called for its side effect of printing findings.
Examples
# Run the CLI entry point over a throwaway project in tempdir().
proj <- file.path(tempdir(), "scilintr-cli-demo")
dir.create(proj, showWarnings = FALSE)
writeLines("z <- 3", file.path(proj, "analysis.R"))
main(proj)
unlink(proj, recursive = TRUE)
proj <- file.path(tempdir(), "scilintr-cli-demo")
dir.create(proj, showWarnings = FALSE)
writeLines("z <- 3", file.path(proj, "analysis.R"))
main(proj)
unlink(proj, recursive = TRUE)