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

Allow multi-line parameters rule to always break lines #3494

Merged
merged 2 commits into from
Feb 2, 2021
Merged

Allow multi-line parameters rule to always break lines #3494

merged 2 commits into from
Feb 2, 2021

Conversation

otaviocc
Copy link
Contributor

@otaviocc otaviocc commented Jan 16, 2021

When I originally implemented the multiline_parameter rule (as @ornithocoder) I made the design choice to allow either all the parameters in one line or one per line. But there are teams which prefer all the parameters to be always in different lines and never on the same line.

This PR adds the support to this use case. Setting allows_single_line to false will enforce that.

func foo(param1: Int,
         param2: Bool,
         param3: [String]) -> AnyPublisher<Response, Error>

And when used in combination with multiline_parameters_brackets it's possible to enforce the following style to all methods with multiple parameters:

func foo(
    param1: Int,
    param2: Bool,
    param3: [String]
) -> AnyPublisher<Response, Error>

@SwiftLintBot
Copy link

SwiftLintBot commented Jan 16, 2021

2 Warnings
⚠️ This PR may need tests.
⚠️ This PR introduced a violation in Sourcery: /SourceryTests/Stub/Performance-Code/Kiosk/App/Networking/NetworkLogger.swift:13:5: warning: Inclusive Language Violation: Declaration init(whitelist:blacklist:) contains the term "blacklist" which is not considered inclusive. (inclusive_language)
13 Messages
📖 Linting Aerial with this PR took 2.07s vs 1.99s on master (4% slower)
📖 Linting Alamofire with this PR took 2.88s vs 2.83s on master (1% slower)
📖 Linting Firefox with this PR took 9.55s vs 9.49s on master (0% slower)
📖 Linting Kickstarter with this PR took 15.45s vs 15.27s on master (1% slower)
📖 Linting Moya with this PR took 1.44s vs 1.41s on master (2% slower)
📖 Linting Nimble with this PR took 1.27s vs 1.29s on master (1% faster)
📖 Linting Quick with this PR took 0.59s vs 0.57s on master (3% slower)
📖 Linting Realm with this PR took 4.08s vs 4.07s on master (0% slower)
📖 Linting SourceKitten with this PR took 1.06s vs 1.04s on master (1% slower)
📖 Linting Sourcery with this PR took 8.27s vs 8.26s on master (0% slower)
📖 Linting Swift with this PR took 11.12s vs 11.08s on master (0% slower)
📖 Linting WordPress with this PR took 18.1s vs 18.1s on master (0% slower)
📖 This PR fixed a violation in Sourcery: /SourceryTests/Stub/Performance-Code/Kiosk/App/Networking/NetworkLogger.swift:13:5: warning: Inclusive Language Violation: Declaration init(whitelist:blacklist:) contains the term "whitelist" which is not considered inclusive. (inclusive_language)

Generated by 🚫 Danger

When I originally implemented this rule, I made a design choice to allow either all the parameter in one line or in multiple lines, but there are cases/teams which prefer to have all the parameters in different lines.

This PR adds the support of this use case. It's nows possible to configure the Multiline Parameters Rule to enforce breaking the list of parameters into multiple lines.
@otaviocc
Copy link
Contributor Author

otaviocc commented Feb 2, 2021

Hi @keith @marcelofabri, do you think this one can make the next release? My team is looking forward to enabling this rule. I can leave without #3505, #3504, and #3495 for now.

@keith keith merged commit 7ea9b73 into realm:master Feb 2, 2021
@keith
Copy link
Collaborator

keith commented Feb 2, 2021

Thanks!

@otaviocc otaviocc deleted the oc/force_multiline branch February 2, 2021 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants