-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid parentheses can cause lintr to error or hang #1427
Comments
Thanks for reporting these two bugs.
|
Is there any reason to attempt running linters if file <- withr::local_tempfile(lines = "function() {)")
get_source_expressions(file)$error
# /tmp/RtmpiT5lal/file1b7cdf709f1728:1:13: error: [NA] unexpected ')'
# function() {)
# ^ BTW, behavior on lint("{ if (x) x()\n")
# Error in generate_top_level_map(parsed_content) :
# Logical error: unassigned set did not shrink. Check file syntax and please report as a lintr bug. |
Bumping to 3.1.0... the change to just not attempt linting for syntax errors feels like a big enough behavior change, and the current HEAD behavior (somewhat cryptic error, but does mention checking syntax) is not so catastrophic that I'm uncomfortable releasing with it. |
The first error is affecting on-the-fly syntax checking. I am using
I get the In fact, Before version
|
@ywwry66 can you confirm you're on the latest dev version? |
Yes I just tested a few minutes ago using devtools::install_github("r-lib/lintr") As comparison, I installed version devtools::install_github("r-lib/lintr", ref="01e57c2") |
You are right. So I guess that also applies to OP's first bug: x = lint("function() {)\n") works just the same. And it is the printing method that fails. Looking at the object List of 3
$ <text>:List of 8
..$ filename : chr "<text>"
..$ line_number : int 1
..$ column_number: int 9
..$ type : chr "style"
..$ message : chr "Remove spaces before the left parenthesis in a function call."
..$ line : chr "function() {)"
..$ ranges :List of 1
.. ..$ : int [1:2] 9 NA
..$ linter : chr "function_left_parentheses_linter"
..- attr(*, "class")= chr [1:2] "lint" "list"
$ <text>:List of 8
..$ filename : chr "<text>"
..$ line_number : int 1
..$ column_number: int 12
..$ type : chr "style"
..$ message : chr "Opening curly braces should never go on their own line and should always be followed by a new line."
..$ line : chr "function() {)"
..$ ranges :List of 1
.. ..$ : int [1:2] 12 12
..$ linter : chr "brace_linter"
..- attr(*, "class")= chr [1:2] "lint" "list"
$ <text>:List of 8
..$ filename : chr "<text>"
..$ line_number : int 1
..$ column_number: int 13
..$ type : chr "error"
..$ message : chr "unexpected ')'"
..$ line : chr "function() {)"
..$ ranges : NULL
..$ linter : chr "error"
..- attr(*, "class")= chr [1:2] "lint" "list"
- attr(*, "class")= chr [1:2] "lints" "list" |
yes... Q is what's the "right" fix. it could be the printing method, or lint(), or Lint(). I still don't know for sure. |
Hey @MichaelChirico! Thanks for your attention to the issue I reported! 🙂 It's perhaps not an ideal place to ask, but I'm not sure how to reach you otherwise... Are you going to release a new version of lintr this week? We've received a mail telling us that lintr 3.0.1 is scheduled for CRAN archival on 2022-10-22 (R CMD check issues) which would lead to archival of rhino too (which I maintain). |
Hi @kamilzyla, Sorry about that. @jimhester has already submitted a patchlast week, which should hopefully be on CRAN soon. So no need to worry 🙃 |
As of now, these issues create error messages: lintr::lint(text = "function() {)")
#> Error: Linter 'indentation_linter' failed in /tmp/Rtmp6VUowy/file157a74b3d19b: missing value where TRUE/FALSE needed
lintr::lint(text = "{ if (x) x()")
#> Error in generate_top_level_map(parsed_content): Logical error: unassigned set did not shrink. Check file syntax and please report as a lintr bug. Created on 2022-12-03 with reprex v2.0.2 |
Steps to reproduce
Run
lintr::lint()
on the following snippets.This one throws
Error in rep.int(character, length) : invalid 'times' value
:function() {)
This one hangs forever:
Expected behavior
The function should exit cleanly and report a human-readable error.
Notes
Tested on version
3.0.0
released to CRAN as well as the development version at commit6c3f0fd
.The text was updated successfully, but these errors were encountered: