Package 'scilintr'

Title: Scientific Code Lint for R Analyses
Description: Static analysis for R scientific data analysis code. Flags patterns that often correspond to hidden scientific commitments -- silent error swallowing, smuggled defaults, label leakage in selection-stage code, magic-eps floors in 'BIC' formulas, and shadow-overwrite of sourced helpers. Designed for agentic coding workflows; high recall over precision; structured 'ANALYSIS_OK' waivers as the audit trail.
Authors: Arjun Raj [aut, cre]
Maintainer: Arjun Raj <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2026-06-12 14:53:27 UTC
Source: https://github.com/cran/scilintr

Help Index


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)

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)

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)

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)

Main CLI entry point.

Description

Invoked from inst/bin/scilintr or ⁠Rscript -e 'scilintr::main()'⁠.

Usage

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)