-
Notifications
You must be signed in to change notification settings - Fork 187
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
Consistent handling of Encodings #782
Conversation
The test file is GPL 2 licensed. I'll replace the file by a self-made one to avoid license violations of spatialprobit. |
1a25d40
to
937419b
Compare
handle invalid encoding in parse_exclusions() and get_source_file() suppress linting of file if invalid encoding detected also had to fix deprecated warnings caused by R 4.1.0 and testthat::expect_equal() with functions
…expects parse error instead of encoding error to be reported)
…e correct encoding.
…it failed the codecov build)
42539d8
to
c5d5cea
Compare
@@ -77,6 +87,36 @@ get_source_expressions <- function(filename, lines = NULL) { | |||
# an error that does not use R_ParseErrorMsg | |||
if (is.na(message_info$line)) { | |||
|
|||
if (grepl("invalid multibyte character in parser at line", e$message, fixed = TRUE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to increase robustness is what we've done in data.table
:
Basically, keep a database (maybe populated at onAttach()
) of error messages as generated by R itself.
That way we don't need to change anything if R updates its own message.
Just a thought, no need to do so in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea. That would also allow us to remove the set_lang()
construct currently in use to force english error messages.
The file is read in using the \code{encoding} setting. | ||
This setting found by taking the first valid result from the following locations | ||
\enumerate{ | ||
\item The \code{encoding} key from the usual lintr configuration settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link to ?default_settings
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?default_settings
needs a little love I think. Currently it contains not much more than "An object of class list of length 12".
Maybe that would be a good place in general to document settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I picked ?default_settings
kind of at random, more that "from the usual lintr configuration settings" won't be helpful if this is the first help page a user sees -- some link to help about what we mean there is needed.
If we don't have such a page yet then yes, let's use ?default_settings
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty weak when it comes to encodings, but the API & testing look basically good to me. Good work!
Implements #752
fixes #541
Added TODO comments to all places that need changing to not miss anything.
Feel free to add more TODO comments if I missed some place.