You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Turn off line length linter within string literals (optionally?) #856
Not sure if we should, but we have a similar problem with long machine-readable comments, so it would be nice to also control linting of comment lines.
What should qualify a line for exclusion in both cases?
E.g. what if a string / comment starts past the max line length?
Giving this a bit more thought, one use case with the string line length issue is with very long paths, where adding newlines to the string is not an option.
Therefor I feel we should exclude the string expression completely, i.e. only lint line_length if new code starts past the end of a long string or is too long in the line before the string starts.
Related: for me the place where the line_length always bites me is with urls.
Not flagging a line that's just a single string with no spaces (or maybe detecting urls specifically?) would be a nice feature.
The no spaces heuristic breaks down for long paths that contain embedded spaces.
That said, it seems very hard to figure out a good heuristic which would neither cause many false-positives nor too many false negatives.
Related: for me the place where the line_length always bites me is with urls. Not flagging a line that's just a single string with no spaces (or maybe detecting urls specifically?) would be a nice feature.
Activity
AshesITR commentedon Sep 13, 2021
Not sure if we should, but we have a similar problem with long machine-readable comments, so it would be nice to also control linting of comment lines.
What should qualify a line for exclusion in both cases?
E.g. what if a string / comment starts past the max line length?
MichaelChirico commentedon Sep 14, 2021
by "bodies" i meant to exclude the first and last line, e.g.
So it seems like we could add two options to the linter:
(1) exclude_comments = FALSE (by default)
(2) exclude_string_bodies = FALSE (by default)
AshesITR commentedon Sep 28, 2021
Giving this a bit more thought, one use case with the string line length issue is with very long paths, where adding newlines to the string is not an option.
Therefor I feel we should exclude the string expression completely, i.e. only lint line_length if new code starts past the end of a long string or is too long in the line before the string starts.
To clarify what I mean:
IINM this behavior could be achieved by treating every string literal as length 0
MichaelChirico commentedon Sep 28, 2021
We do have loads of long file names, but usually it's because of the leading directories, and that can be solved using
file.path().OTOH, we also have a lot of SQL table names / nested column structures accessed with
.that more awkward to split usingpaste0orpaste(sep = '.').d-sci commentedon Oct 15, 2021
Related: for me the place where the line_length always bites me is with urls.
Not flagging a line that's just a single string with no spaces (or maybe detecting urls specifically?) would be a nice feature.
I often find myself doing something like:
AshesITR commentedon Oct 15, 2021
NB for Stackexchange specifically, you can shorten the URL drastically:
https://math.stackexchange.com/questions/2971315/how-do-i-combine-standard-deviations-of-two-groups
Is equivalent to
https://math.stackexchange.com/q/2971315
The no spaces heuristic breaks down for long paths that contain embedded spaces.
That said, it seems very hard to figure out a good heuristic which would neither cause many false-positives nor too many false negatives.
MichaelChirico commentedon Aug 4, 2023
Hmm, I might lint in the first case, requiring the string literal to be "alone" on the line to be exempted:
read_csv( "very_long_path.csv" )"alone" because the latter case, where the string is the target of an
EQ_SUB, would be OK since forcing this is somewhat awkward:Note to self that we'll also have to exclude the
OP-COMMAon the same line, if present.MichaelChirico commentedon Sep 18, 2023
@d-sci ICYMI you can now (in dev & soon on CRAN) switch to
# nolint nextif that's better for you: