Skip to content

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

Closed

Description

@maikol-solis

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.

Activity

  1. IndrajeetPatil commented on Apr 20, 2024

    @IndrajeetPatil
    Contributor

    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

  2. maikol-solis commented on Apr 20, 2024

    @maikol-solis
    Author

    Thanks for the tip.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions