Repository navigation
[Linting Rule] S3 Method Consistency
Generated from 'wiki-linter.ts' on 2026-10-25, 09:29:25 UTC (v2.16.6), do not edit directly.
S3 Method Consistency [overview]
This rule ports the following steps of R CMD check (see the conformance table for the legend):
| # | Step | Coverage | Note |
|---|---|---|---|
| 38 | S3 generic/method consistency (book) | 🟩⭐ | ⭐ also apparent and unregistered methods without setting an environment variable |
| 39 | replacement functions (book) | 🟩⭐ | ⭐ also apparent replacement methods |
| 41 | use of S3 registration (book) | 🔷 | overwriting registered methods of standard packages is not checked |
This rule is a best-effort rule.
Finds S3 methods whose formals do not match their generic, methods not registered in the NAMESPACE, and replacement functions whose last formal is not value.
This linting rule is implemented in src/linter/rules/cmd-check/s-three-method-consistency.ts.
Linting rules can be configured by passing a configuration object to the linter query as shown in the example below.
The s3-method-consistency rule accepts the following configuration options:
-
checkApparentMethods
also check functions named like a method but not registered in theNAMESPACE, whichR CMD checkonly does on request (defaulttrue)
R CMD check #38 -
checkMethods
check that methods take the arguments of their generic (defaulttrue)
R CMD check #38 -
checkReplacementValues
check that replacement functions end invalue(defaulttrue)
R CMD check #39 -
checkUnregistered
report apparent methods of an exported generic that theNAMESPACEdoes not register (defaulttrue)
R CMD check #41
print.myclass <- function(obj) cat("myclass")
`size<-` <- function(x, v) { attr(x, "size") <- v; x }The linting query can be used to run this rule on the above example:
[ { "type": "linter", "rules": [ { "name": "s3-method-consistency", "config": {} } ] } ]Results (prettified and summarized):
Query: linter (70 ms)
╰ S3 Method Consistency (s3-method-consistency):
╰ certain:
╰ size<-: replacement-value at 2.1-8
More examples are the test cases in test/functionality/linter/cmd-check/lint-s-three-method-consistency.test.ts.
Currently maintained by Florian Sihler and Oliver Gerstl at Ulm University
Email | GitHub | Penguins | Portfolio
- 🧑💻 Developer Onboarding
- 💻 Setup
- 👓 Overview
- 🪟 Interfacing with flowR
- 🌋 Core
- 🧹 Testing & Linting (Benchmark Page)
⁉️ FAQ- ℹ️ Extra Information