A 'Linter' for R Code
Absolute path linter
Warn about invalid usage of all.equal()
Create a linter configuration based on all available linters
Require usage of anyDuplicated(x) > 0 over any(duplicated(x))
Require usage of anyNA(x) over any(is.na(x))
Assignment linter
Get Linter metadata from a package
Backport linter
Best practices linters
Require usage of boolean operators over equivalent arithmetic
Brace linter
Checkstyle Report for lint results
Block comparison of class with ==
Clear the lintr cache
Encourage usage of the null coalescing operator %||%
Commas linter
Commented code linter
Common mistake linters
Block usages like !(x == y) where a direct relational operator is appr...
Recommend usage of call. = FALSE in conditions
Block usage of paste() and paste0() with messaging functions using...
Configurable linters
Force && conditions to be written separately where appropriate
Force consecutive calls to assertions into just one when possible
Require consecutive calls to mutate() to be combined when possible
Consistency linters
Correctness linters
Cyclomatic complexity linter
Default linters
Default lintr settings
Default undesirable functions and operators
Deprecated linters
Recommend usage of a portable mode value for downloading files
Duplicate argument linter
Efficiency linters
Block assignment of {}
Equality check with NA linter
Exclude lines or files from linting
Code executing linters
Require usage of expect_gt(x, y) over expect_true(x > y) (and simi...
Require usage of expect_identical(x, y) where appropriate
Require usage of expect_length(x, n) over `expect_equal(length(x), n...
Test that the package is lint free
Lint expectation
Require usage of expect_named(x, n) over expect_equal(names(x), n)
Require usage of expect_false(x) over expect_true(!x)
Require usage of expect_null for checking NULL
Require usage of expect_s3_class()
Require usage of expect_s4_class(x, k) over expect_true(is(x, k))
Require usage of expect_true(x) over expect_equal(x, TRUE)
Require usage of expect_type(x, type) over `expect_equal(typeof(x), ...
Require usage of fixed=TRUE in regular expressions where appropriate
Block usage of for loops directly overwriting the indexing variable
Function argument linter
Function left parentheses linter
Lint common mistakes/style issues cropping up from return statements
Extract text from STR_CONST nodes
Parsed sourced file from a filename
GitLab Report for lint results
Get parsed IDs by token
Block statements like if (!A) x else y
Require usage of switch() over repeated if/else blocks
Block usage of ifelse() where pmin() or pmax() is more appropria...
Avoid implicit assignment in function calls
Implicit integer linter
Check that indentation is consistent
Infix spaces linter
Require c() to be applied before relatively expensive vectorized fun...
Is this an expression- or a file-level source object?
Redirect is.numeric(x) || is.integer(x) to just use is.numeric(x)
Block unnecessary quoting in calls
Require usage of nlevels over length(levels(.))
Check for a common mistake where a size check like 'length' is applied...
Require usage of lengths() where possible
Library call linter
Line length linter
Create a lint object
Lint a file, directory, or package
Create a linter closure
Create a linter configuration based on defaults
Create a tag-based linter configuration
Available linters
Deprecated functions in lintr
Lintr
Block usage of comparison operators with known-list() functions like l...
Recommend direct usage of data.frame() to create a data.frame from a...
Require usage of correctly-typed literals over literal coercions
Create a linter from an XPath
Require usage of colSums(x) or rowSums(x) over apply(x, ., sum)
Missing argument linter
Missing package linter
Modify lintr defaults
Namespace linter
Block usage of nested ifelse() calls
Block usage of pipes nested inside other calls
Non-portable path linter
Normalize lint exclusions
Block usage of nrow(subset(x, .))
Require usage of a leading zero in all fractional numerics
Require usage of nzchar where appropriate
Object length linter
Object name linter
Block assigning any variables whose name clashes with a base R funct...
Object usage linter
Block single-call magrittr pipes
Require usage of !any(x) over all(!x), !all(x) over any(!x)
Package development linters
Package hooks linter
Parenthesis before body linter
read a source file and parse all the excluded lines from it
Raise lints for several common poor usages of paste()
Pipe call linter
Pipe consistency linter
Pipe continuation linter
Block usage of return() in magrittr pipelines
Testthat linters
Block usage of print() for logging
Character string quote linter
Read lintr settings
Readability linters
Block usage of ==, != on logical vectors
Prevent ifelse() from being used to produce TRUE/FALSE or 1/`0...
Regular expression linters
Require usage of direct methods for subsetting strings via regex
Require usage of rep_len(x, n) over rep(x, length.out = n)
Repeat linter
Return linter
Robustness linters
Identify unregistered native routines
Require usage of sample.int(n, m, ...) over sample(1:n, m, ...)
SARIF Report for lint results
Block usage like x %in% "a"
Semicolon linter
Sequence linter
Check for common mistakes around sorting vectors
Spaces inside linter
Spaces before parentheses linter
Require correct sprintf() calls
Block usage of all() within stopifnot()
Require usage of startsWith() and endsWith() over grepl()/`subst...
Identify cases where stringsAsFactors should be supplied explicitly
Style linters
Block usage of file.path() with system.file()
T and F symbol linter
Prohibit close() from terminating a function definition
Tidyverse design linters
TODO comment linter
Trailing blank lines linter
Trailing whitespace linter
Undesirable function linter
Undesirable operator linter
Unneeded concatenation linter
Block usage of anonymous functions in iteration functions when unneces...
Block instances of unnecessary nesting
Block usage of pipeline placeholders if unnecessary
Block unreachable code and comments following return statements
Check that imported packages are actually used
Use lintr in your project
Enforce usage of scalar logical operators in conditional statements
Require usage of grep over which(grepl(.))
Whitespace linter
Convert an XML node or nodeset into a Lint
Get the name of the function matched by an XPath
Block obvious "yoda tests"
Checks adherence to a given style, syntax errors and possible semantic issues. Supports on the fly checking of R code edited with 'RStudio IDE', 'Emacs', 'Vim', 'Sublime Text', 'Atom' and 'Visual Studio Code'.
Useful links