Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

with_defaults

Modify lintr defaults


Description

Make a new list based on lintr's default linters, undesirable operators or functions. The result of this function is meant to be passed to the 'linters' argument of 'lint()', or put in your configuration file.

Usage

with_defaults(..., default = default_linters)

Arguments

...

arguments of elements to change. If unnamed, the argument is named. If the named argument already exists in "default", it is replaced by the new element. If it does not exist, it is added. If the value is NULL, the element is removed.

default

list of elements to modify.

Value

A modified list of elements.

Examples

# When using interatively you will usuaully pass the result onto `lint` or `lint_package()`
## Not run: 
lint("foo.R", linters = with_defaults(line_length_linter = line_length_linter(120)))

## End(Not run)
# the default linter list with a different line length cutoff
my_linters <- with_defaults(line_length_linter = line_length_linter(120))

# omit the argument name if you are just using different arguments
my_linters <- with_defaults(default = my_linters,
                            object_name_linter("camelCase"))

# remove assignment checks (with NULL), add absolute path checks
my_linters <- with_defaults(default = my_linters,
                            assignment_linter = NULL,
                            absolute_path_linter)

# custom list of undesirable functions:
#    remove sapply (using NULL)
#    add cat (with a accompanying message),
#    add print (unnamed, i.e. with no accompanying message)
#    add return (as taken from all_undesirable_functions)
my_undesirable_functions <- with_defaults(default = default_undesirable_functions,
  sapply=NULL, "cat"="No cat allowed", "print", all_undesirable_functions[["return"]])

lintr

A 'Linter' for R Code

v2.0.1
MIT + file LICENSE
Authors
Jim Hester [aut, cre], Florent Angly [aut], Russ Hyde [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.