yoda_test_linter {lintr}R Documentation

Block obvious "yoda tests"

Description

Yoda tests use ⁠(expected, actual)⁠ instead of the more common ⁠(actual, expected)⁠. This is not always possible to detect statically; this linter focuses on the simple case of testing an expression against a literal value, e.g. ⁠(1L, foo(x))⁠ should be ⁠(foo(x), 1L)⁠.

Usage

yoda_test_linter()

Tags

best_practices, package_development, readability

See Also

linters for a complete list of linters available in lintr. https://en.wikipedia.org/wiki/Yoda_conditions


[Package lintr version 3.0.0 Index]