Skip to content

Commit

Permalink
mnt: Add implicit_integer_linter and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MEO265 committed May 30, 2024
1 parent 11603ad commit 591d049
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ linters: list(
if_not_else_linter(),
ifelse_censor_linter(),
# implicit_assignment_linter(allow_scoped = TRUE), # Is bugged
# implicit_integer_linter(allow_colon = TRUE),
implicit_integer_linter(allow_colon = TRUE),
indentation_linter(),
infix_spaces_linter(),
inner_combine_linter(),
Expand Down Expand Up @@ -61,7 +61,7 @@ linters: list(
repeat_linter(),
routine_registration_linter(),
scalar_in_linter(),
# semicolon_linter(),
# semicolon_linter(), # Wanted in tests
seq_linter(),
sort_linter(),
spaces_inside_linter(),
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-handlers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("message works as it does in base R", {
expect_identical_message(message(), base::message())
expect_identical_message(message("this is a message test"), base::message("this is a message test"))
expect_identical_message(message("this", "is a", "message test"), base::message("this", "is a", "message test"))
expect_identical_message(message("Some numbers", 3, 1:5, "!"), base::message("Some numbers", 3, 1:5, "!"))
expect_identical_message(message("Some numbers", 3L, 1:5, "!"), base::message("Some numbers", 3L, 1:5, "!"))

# message works as in base R (with echo = FALSE)
expect_identical_message(message(echo = FALSE), base::message(), ignore_call = TRUE)
Expand Down Expand Up @@ -44,7 +44,7 @@ test_that("warning works as it does in base R", {
expect_identical_warning(warning(), base::warning())
expect_identical_warning(warning("this is a warning test"), base::warning("this is a warning test"))
expect_identical_warning(warning("this", "is a", "warning test"), base::warning("this", "is a", "warning test"))
expect_identical_warning(warning("Some numbers", 3, 1:5, "!"), base::warning("Some numbers", 3, 1:5, "!"))
expect_identical_warning(warning("Some numbers", 3L, 1:5, "!"), base::warning("Some numbers", 3L, 1:5, "!"))

# warning works as in base R (with echo = FALSE)
expect_identical_warning(warning(echo = FALSE), base::warning())
Expand Down Expand Up @@ -80,7 +80,7 @@ test_that("stop works as it does in base R", {
expect_identical_error(stop(), base::stop())
expect_identical_error(stop("this is a stop test"), base::stop("this is a stop test"))
expect_identical_error(stop("this", "is a", "stop test"), base::stop("this", "is a", "stop test"))
expect_identical_error(stop("Some numbers", 3, 1:5, "!"), base::stop("Some numbers", 3, 1:5, "!"))
expect_identical_error(stop("Some numbers", 3L, 1:5, "!"), base::stop("Some numbers", 3L, 1:5, "!"))

# stop works as in base R (with echo = FALSE)
expect_identical_error(stop(echo = FALSE), base::stop())
Expand Down Expand Up @@ -114,26 +114,26 @@ test_that("stopifnot", {
f <- function(x, ...) x
expect_identical_error(stopifnot(f(x = FALSE)), base::stopifnot(f(x = FALSE)))
g <- function() f(FALSE)
expect_identical_error(stopifnot(4 == 4, g()), base::stopifnot(4 == 4, g()))
expect_identical_error(stopifnot(4 == 4, Test = g()), base::stopifnot(4 == 4, Test = g()))
expect_identical_error(stopifnot(4L == 4L, g()), base::stopifnot(4L == 4L, g()))
expect_identical_error(stopifnot(4L == 4L, Test = g()), base::stopifnot(4L == 4L, Test = g()))
expect_identical_error(stopifnot(exprs = { TRUE; FALSE }), base::stopifnot(exprs = { TRUE; FALSE }))
expect_identical_error(stopifnot(exprObject = { TRUE; FALSE }), base::stopifnot(exprObject = { TRUE; FALSE }))
expect_no_error(stopifnot(TRUE, 3 == 3))
expect_no_error(stopifnot(TRUE, 3L == 3L))

# stopifnot works as in base R (with echo = FALSE)
expect_no_error(stopifnot(echo = FALSE))
expect_identical_error(stopifnot(FALSE, echo = FALSE), base::stopifnot(FALSE))
f <- function(x, ...) x
expect_identical_error(stopifnot(f(x = FALSE), echo = FALSE), base::stopifnot(f(x = FALSE)))
g <- function() f(FALSE)
expect_identical_error(stopifnot(4 == 4, g(), echo = FALSE), base::stopifnot(4 == 4, g()))
expect_identical_error(stopifnot(4 == 4, "A Test" = g(), echo = FALSE), base::stopifnot(4 == 4, "A Test" = g()))
expect_identical_error(stopifnot(4L == 4L, g(), echo = FALSE), base::stopifnot(4L == 4L, g()))
expect_identical_error(stopifnot(4L == 4L, "A Test" = g(), echo = FALSE), base::stopifnot(4L == 4L, "A Test" = g()))
expect_identical_error(stopifnot(exprs = { TRUE; FALSE }, echo = FALSE), base::stopifnot(exprs = { TRUE; FALSE }))
expect_identical_error(
stopifnot(exprObject = { TRUE; FALSE }, echo = FALSE),
base::stopifnot(exprObject = { TRUE; FALSE })
)
expect_no_error(stopifnot(TRUE, 3 == 3, echo = FALSE))
expect_no_error(stopifnot(TRUE, 3L == 3L, echo = FALSE))

cleanup()

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-loggit.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_that("loggit multiplies values with warning", {
)

expect_warning(
loggit(log_lvl = "INFO", log_msg = c("foo", "bar"), value = 1, echo = FALSE),
loggit(log_lvl = "INFO", log_msg = c("foo", "bar"), value = 1L, echo = FALSE),
regexp = "^log_msg should be of length one, only the first element will be used.$"
)

Expand All @@ -42,7 +42,7 @@ test_that("loggit multiplies values with warning", {
)

expect_error(
loggit(log_lvl = "INFO", log_msg = "foo", value = 1, "4", echo = FALSE),
loggit(log_lvl = "INFO", log_msg = "foo", value = 1L, "4", echo = FALSE),
regexp = "^All custom log fields should be named.$"
)

Expand Down
4 changes: 2 additions & 2 deletions vignettes/loggit2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ knitr::opts_chunk$set( #nolint
collapse = TRUE,
comment = "#>"
)
old <- options(width = 200)
old <- options(width = 200L)
```

`loggit2` is an easy-to-use, yet powerful, [`ndjson`](https://github.com/ndjson)
Expand Down Expand Up @@ -114,7 +114,7 @@ fun_a <- function(x) {
fun_b <- function(x) {
base::warning("This is a second warning")
5 + 5
5L + 5L
}
```

Expand Down

0 comments on commit 591d049

Please sign in to comment.