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

Ignore back ticked function names in max_line_length rule #1007

Closed
paul-dingemans opened this issue Dec 12, 2020 · 3 comments
Closed

Ignore back ticked function names in max_line_length rule #1007

paul-dingemans opened this issue Dec 12, 2020 · 3 comments

Comments

@paul-dingemans
Copy link
Collaborator

When writing unit tests, it is a common pattern enclose the function name enclosed between back-ticks. Those function names can however not be split into multiple lines. Therefore such function names should be excludes from the max_line_length rule.

@Test
fun `Should return something when passing something and something and the other thing is in this or that state`() {...}

Originally posted by @k1dbl4ck in #659 (comment)
Would like to add that back ticked function names in tests should also be handled / ignored:

paul-dingemans pushed a commit to paul-dingemans/ktlint that referenced this issue Dec 12, 2020
Tokens starting and ending with a backtick should be ignored entirely
when validating whether a line exceeds the maximum length of a line.
Such tokens can not be spit into multiple lines. For example when
writing JUnit test it is a common pattern to write the function names
between back ticks instead of using the DisplayName annotation.
@Tapchicoma
Copy link
Collaborator

I am not sure that ktlint should allow such behaviour by default. In the the end max line constraint exists to ensure that code is readable on width constraint text areas.

Probably could be optionally enabled via .editorconfig.

@pauldingemans
Copy link

That is a fair point. I will make it optional.

romtsn pushed a commit that referenced this issue Mar 7, 2021
* Ignore tokens between backticks in rule max line length (#1007)

Tokens starting and ending with a backtick should be ignored entirely
when validating whether a line exceeds the maximum length of a line.
Such tokens can not be spit into multiple lines. For example when
writing JUnit test it is a common pattern to write the function names
between back ticks instead of using the DisplayName annotation.
@romtsn
Copy link
Collaborator

romtsn commented Mar 8, 2021

Closed by #1008

@romtsn romtsn closed this as completed Mar 8, 2021
romtsn pushed a commit to paul-dingemans/ktlint that referenced this issue Aug 8, 2021
…) (pinterest#1008)

* Ignore tokens between backticks in rule max line length (pinterest#1007)

Tokens starting and ending with a backtick should be ignored entirely
when validating whether a line exceeds the maximum length of a line.
Such tokens can not be spit into multiple lines. For example when
writing JUnit test it is a common pattern to write the function names
between back ticks instead of using the DisplayName annotation.
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

4 participants