Skip to content

[Linting Rule] Documentation Mismatch

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-11-08, 14:25:27 UTC (v2.17.4), do not edit directly.

Documentation Mismatch [overview]

bug cmd-check 44, 48–50 documentation

This rule ports the following steps of R CMD check (see the conformance table for the legend):

# Step Coverage Note
44 package namespace information (book) 🔶
48 for missing documentation entries (book) 🟩 S4 classes and methods are not checked
49 for code/documentation mismatches (book) 🟩 data sets and S4 classes are not compared
50 Rd \usage sections (book) 🟩

This rule is a best-effort rule.

Finds exported objects without documentation, functions whose formals differ from their \usage, and arguments missing from or extra in \arguments.
This linting rule is implemented in src/linter/rules/cmd-check/documentation-mismatch.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The documentation-mismatch rule accepts the following configuration options:

  • checkCodoc
    report functions whose formals differ from their \usage
    R CMD check #49
  • checkDefaults
    also report default values that differ between the code and its \usage
    R CMD check #49
  • checkInternalUsage
    also check the \usage of pages with the keyword internal
    R CMD check #50
  • checkUndocumented
    report exported objects no Rd page documents
    R CMD check #48
  • checkUsage
    report arguments of a \usage that its \arguments do not document, and documented arguments no \usage has
    R CMD check #50
  • requireDocumentation
    report undocumented objects even when the package has no Rd pages at all
    R CMD check #48

Examples

A project with the code R/code.R:

f <- function(x, y) x + y

and the files

DESCRIPTION:

Package: pkg
Version: 1.0
Title: A Package
License: MIT

NAMESPACE:

export(f)

man/f.Rd:

\name{f}
\alias{f}
\title{Add}
\usage{f(x)}
\arguments{\item{x}{a number}}

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "documentation-mismatch",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (11 ms)
   ╰ Documentation Mismatch (documentation-mismatch):
       ╰ certain:
           ╰ Codoc mismatches from Rd file 'f.Rd': f(x) in the docs, but f(x, y) in the code at /pkg/man/f.Rd:4.8

More examples are the test cases in test/functionality/linter/cmd-check/lint-documentation-mismatch.test.ts.

Clone this wiki locally

⌂ 换网址