Skip to content
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

Error in rep.int(character, length) : invalid 'times' value #1953

Closed
epruesse opened this issue Apr 6, 2023 · 6 comments · Fixed by #1960
Closed

Error in rep.int(character, length) : invalid 'times' value #1953

epruesse opened this issue Apr 6, 2023 · 6 comments · Fixed by #1960
Labels
bug an unexpected problem or unintended behavior

Comments

@epruesse
Copy link

epruesse commented Apr 6, 2023

> install.packages("lintr")
[...]
> lintr::lint_dir("R")
...................................................
Error in rep.int(character, length) : invalid 'times' value

Is there any way to make it tell me at least what file it errored out in? Or which line in the lintr code? Anything? I know this bug report is supremely unhelpful, but there is nothing else I've got.

@MichaelChirico
Copy link
Collaborator

Sorry about that. Are you using the latest dev version? I thought this error was fixed already.

@epruesse
Copy link
Author

epruesse commented Apr 6, 2023

Thanks for super fast reply!

I was using CRAN. With github main branch version it's telling me this:

.Error: Linter 'function_left_parentheses_linter' failed in {some.R}: 
All entries in `ranges` must satisfy 0 <= range[1L] <= range[2L] <= nchar(line) + 1 (28).

At least I know which linter broke in which file now. Still wondering which line(s) caused the linter to break though.

@epruesse
Copy link
Author

epruesse commented Apr 6, 2023

Hmm. It seems to be doing that for all my files. Odd.

@epruesse
Copy link
Author

epruesse commented Apr 6, 2023

Ahh! Because of the way emacs indents my R, I'm writing my functions like this:

slack_message <- function
(
     txt,
     ...,
     channel = config::get("slack")$channel,
     username = config::get("slack")$username,
     token = NULL
) {
...
}

If I put the ( on the same line as function, the parameters hang so far to the right I'm running out of columns. I suppose I could try and fix the ESS indentation somehow. Still, I suppose lintr shouldn't just error out?

@MichaelChirico MichaelChirico added the bug an unexpected problem or unintended behavior label Apr 6, 2023
@MichaelChirico
Copy link
Collaborator

thanks! I agree we shouldn't error.

you may be interested in the new double indent style for functions in the tidyverse guide:

https://style.tidyverse.org/functions.html#long-lines-1

@epruesse
Copy link
Author

epruesse commented Apr 7, 2023

That looks almost like what I've been doing. I'm indenting function args same depth as code, giving ) { it's own line to make separation visually distinctive.

The trick to getting TheOneTrueEditor to indent according to double indent style was (setq-local ess-align-arguments-in-calls '()) (turns off special indenting for arguments in function definitions).

It'll do until we get black for R (blackr?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants