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

Closing, I used wrong template (TrimMultilineRawString support for alternate trimming methods) #5414

Closed
samuelneff opened this issue Oct 14, 2022 · 1 comment
Labels

Comments

@samuelneff
Copy link

The TrimMultilineRawString (#5051) rule can be helpfully extended to allow custom trimming functions and chained functions.

Expected Behavior

Here is an example from our codebase:

fun String.collapseWhitespace(text: String) =
    trim().replace(Regex("\\s\\s+"), " ")

val blockWithoutAnyExtraWhitespace = """
    This is some text.

    Here is another line; spaced apart.
""".collapseWhitespace()

println(blockWithoutAnyExtraWhitespace)
// Prints: This is some text. Here is another line; spaced apart.

Current Behavior

Currently the rule requires trimIndent() or trimMargin() be called and nothing else is considered valid.

Context

See above example from our codebase that fails this rule but we would like to be able to pass.
Configuration with this change would include an additional option:

TrimMultilineRawString:
  additionalTrimmingMethods:
    - collapseWhitespace

Note: I'm working on another rule now for Hacktoberfest. If I actually get one done, I'll look into implementing this as well. Looks straightforward. Thanks for this great new rule!

@samuelneff samuelneff changed the title TrimMultilineRawString support for alternate trimming methods Closing, I used wrong template (TrimMultilineRawString support for alternate trimming methods) Oct 14, 2022
@samuelneff
Copy link
Author

I used the wrong template. See replacement issue #5415.

Sorry.

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

No branches or pull requests

1 participant