1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/expect_comparison_linter.R
\name{expect_comparison_linter}
\alias{expect_comparison_linter}
\title{Require usage of \code{expect_gt(x, y)} over \code{expect_true(x > y)} (and similar)}
\usage{
expect_comparison_linter()
}
\description{
\code{\link[testthat:comparison-expectations]{testthat::expect_gt()}}, \code{\link[testthat:comparison-expectations]{testthat::expect_gte()}}, \code{\link[testthat:comparison-expectations]{testthat::expect_lt()}},
\code{\link[testthat:comparison-expectations]{testthat::expect_lte()}}, and \code{\link[testthat:equality-expectations]{testthat::expect_equal()}} exist specifically
for testing comparisons between two objects. \code{\link[testthat:logical-expectations]{testthat::expect_true()}} can
also be used for such tests, but it is better to use the tailored function
instead.
}
\examples{
# will produce lints
lint(
text = "expect_true(x > y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x <= y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x == (y == 2))",
linters = expect_comparison_linter()
)
# okay
lint(
text = "expect_gt(x, y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_lte(x, y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_identical(x, y == 2)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x < y | x > y^2)",
linters = expect_comparison_linter()
)
}
\seealso{
\link{linters} for a complete list of linters available in lintr.
}
\section{Tags}{
\link[=best_practices_linters]{best_practices}, \link[=package_development_linters]{package_development}, \link[=pkg_testthat_linters]{pkg_testthat}
}
|