-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
safer Lint(), xml_nodes_to_lints() and lint() (#1788)
* safer Lint(), xml_nodes_to_lints() and lint() * add missing newline * add more checks to Lint() fixes #763 * fix surfaced errors in our own code * fix cyclocomp * avoid apply(..., simplify = FALSE) (R >= 4.1), try fixing r-devel * delint * line should have been line_number * more line fixups * reorder column == 0 case * fix column number problems in r-devel move column_number to nchar(line) + 1L if it's larger anchor end-of-line parse error lints to nchar(line) + 1 as well instead of nchar(line) * feedback * fix tests * fix apparent typo Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
- Loading branch information
1 parent
354d4ee
commit a936cf6
Showing
11 changed files
with
211 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
test_that("Lint() errors on invalid input", { | ||
dummy_line <- "abc" | ||
expect_error( | ||
Lint("dummy.R", line = dummy_line, column_number = NA_integer_), | ||
rex::rex("`column_number` must be an integer between 0 and nchar(line) + 1 (4). It was NA.") | ||
) | ||
expect_error( | ||
Lint("dummy.R", line = dummy_line, line_number = 0L), | ||
rex::rex("`line_number` must be a positive integer. It was 0.") | ||
) | ||
expect_error( | ||
Lint("dummy.R", ranges = c(1L, 3L)), | ||
rex::rex("`ranges` must be NULL or a list.") | ||
) | ||
expect_error( | ||
Lint("dummy.R", ranges = list(1L)), | ||
rex::rex("`ranges` must only contain length 2 integer vectors without NAs.") | ||
) | ||
expect_error( | ||
Lint("dummy.R", ranges = list(c(1L, NA_integer_))), | ||
rex::rex("`ranges` must only contain length 2 integer vectors without NAs.") | ||
) | ||
expect_error( | ||
Lint("dummy.R", line = dummy_line, ranges = list(c(1L, 2L), c(1L, 5L))), | ||
rex::rex("All entries in `ranges` must satisfy 0 <= range[1L] <= range[2L] <= nchar(line) + 1 (4).") | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters