Learn R Programming

lintr (version 3.1.2)

sprintf_linter: Require correct sprintf() calls

Description

Check for an inconsistent number of arguments or arguments with incompatible types (for literal arguments) in sprintf() calls.

Usage

sprintf_linter()

Arguments

Tags

common_mistakes, correctness

Details

gettextf() calls are also included, since gettextf() is a thin wrapper around sprintf().

See Also

linters for a complete list of linters available in lintr.

Examples

Run this code
# will produce lints
lint(
  text = 'sprintf("hello %s %s %d", x, y)',
  linters = sprintf_linter()
)

# okay
lint(
  text = 'sprintf("hello %s %s %d", x, y, z)',
  linters = sprintf_linter()
)

lint(
  text = 'sprintf("hello %s %s %d", x, y, ...)',
  linters = sprintf_linter()
)

Run the code above in your browser using DataLab