INWTLinters: INWT's own linters

INWTLintersR Documentation

INWT's own linters

Description

Linters added by INWT. Usually not called directly but used with lint.

Usage

double_space_linter()

internal_function_linter()

setwd_linter()

source_linter()

options_linter()

sapply_linter()

trailing_whitespaces_linter()

double_space_linter()

Functions

  • double_space_linter(): Are there double whitespaces?

  • internal_function_linter(): Internal functions should not be used since there is in general a reason why they have not been exported by the package author. They may not have been tested outside the context of the function they are used in.

  • setwd_linter(): Changing the working directory in package functions can have unexpected side effects. (only for package functions)

  • source_linter(): Sourcing files in package functions can have unexpected side effects. (only for package functions)

  • options_linter(): Changing options in package functions can have unexpected side effects and is not visible from the outside. (only for package functions)

  • sapply_linter(): The automatic simplification performed by sapply introduces uncertainty. If the input changes, the output can change unexpectedly and the code crashes. Replace it with sapply. If you use sapply with simplify = FALSE, it is equivalent to lapply anyway.

  • trailing_whitespaces_linter(): Trailing whitespaces are superfluos. In contrast to trailing_whitespace_linter, this function detects whitespaces after %>% only if there are at least two (since one whitespace is inserted automatically after %>%).

  • double_space_linter(): Are there double whitespaces?

Examples

## Not run: 
writeLines(con = "lintExample.txt",
# nolint start
           text = c("# Example script to demonstrate INWT's own linters",
                    "",
                    "source(anotherScript.R)",
                    "",
                    "foo <- function(x = 1, y) {",
                    "  2 * x + 1  ",
                    "}",
                    "",
                    "# This  line contains  double spaces",
                    "",
                    "print(INWTUtils:::scriptLinters())"))
# nolint end
lintr::lint("lintExample.txt",
     linters = list(argsWithoutDefault = function_argument_linter,
                    doubeWhitespace = double_space_linter,
                    sourceLinter = source_linter))

## End(Not run)


INWT/INWTUtils documentation built on May 22, 2024, 4:45 p.m.