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

Disagreement with styler and lintr about long lines. Rstudio gives a better format #1192

Closed
maikol-solis opened this issue Apr 20, 2024 · 2 comments

Comments

@maikol-solis
Copy link

Hi!

I have this problem. Suppose you have this long line in your code:

value <- my_function(arg0 = 0, arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5, arg6 = 6, arg7 = 7)

Checking it with styler, returns the unmodified string.

styler::style_text("value <- my_function(arg0 = 0, arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5, arg6 = 6, arg7 = 7)")
value <- my_function(arg0 = 0, arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5, arg6 = 6, arg7 = 7)

However, lintr is complaining about the length of the line

[line_length_linter]: Lines should not be more than 80 characters. This line is 100 characters.	

In my opinion, Rstudio gives a better format:

value <-
  my_function(
    arg0 = 0,
    arg1 = 1,
    arg2 = 2,
    arg3 = 3,
    arg4 = 4,
    arg5 = 5,
    arg6 = 6,
    arg7 = 7
  )

What can I do to make styler behave like Rstudio in this case?

Best.

@IndrajeetPatil
Copy link
Collaborator

Closing in favour of #247

If you want to avoid the lint, you can change the length limit in the lintr config:

library(lintr)

lint(
  text = "value <- my_function(arg0 = 0, arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5, arg6 = 6, arg7 = 7)",
  linters = line_length_linter(120L)
)

Created on 2024-04-20 with reprex v2.1.0

@maikol-solis
Copy link
Author

Thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants