Skip to content

[Linting Rule] Bogus Return

github-actions[bot] edited this page Oct 25, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-10-25, 09:29:25 UTC (v2.16.6), do not edit directly.

Bogus Return [overview]

bug cmd-check 37 quickfix

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

# Step Coverage Note
37 R code for possible problems (book) 🟩⭐ ⭐ also quick fixes, deprecated arguments, environments resolved through variables, hooks followed into callees

This rule is a exact rule.

Finds a bare return (without ()), which evaluates to the function return instead of returning. Offers return() as a quick fix.
This linting rule is implemented in src/linter/rules/cmd-check/bogus-return.ts.

Examples

f <- function(x) {
	if(is.null(x)) return
	x + 1
}

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

[ { "type": "linter",   "rules": [ { "name": "bogus-return",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (1 ms)
   ╰ Bogus Return (bogus-return):
       ╰ certain:
           ╰ Bare return at 2.17-22 (1 quick fix(es) available)

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

Clone this wiki locally