checkStyle: Check code style

View source: R/02_checkStyle.R

checkStyleR Documentation

Check code style

Description

Checks a file for violations of the INWT style conventions using lint. The linters are partly taken from the package lintr, and partly from this package.

Usage

checkStyle(files, linters = selectLinters(...), ...)

Arguments

files

character vector: One or more filepaths

linters

list: Named list of used linter functions

...

Arguments passed to selectLinters

Details

Per default, the used linters are selected via selectLinters. If you pass a list of linters directly via the linters argument, all arguments passed to selectLinters via ... will be ignored.

Examples

## Not run: 
writeLines(con = "lintExample.txt",
           text = c("# Example script to demonstrate INWT's own linters",
           # nolint start
                    "",
                    "foo <- function(x = 1, y) {",
                    "  2*x + 1",
                    "}",
                    "",
                    paste0("# This  line contains  double spaces and is ",
                           "very long. The following lines will use = ",
                           "instead of <- and access an internal INWT ",
                           "function."),
                    "z = 1",
                    "print(INWTUtils:::scriptLinters())",
                    ""))
           # nolint end
checkStyle("lintExample.txt", type = "script")
unlink("lintExample.txt") # Remove file

## End(Not run)


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