Skip to content

Conversation

@lukepistrol
Copy link
Member

@lukepistrol lukepistrol commented Jan 14, 2023

Description

Multiline parameter/argument indentation and alignment was all over the place which makes code very hard to read and maintain. This PR fixes and from now on enforces alignment of multiline arguments like shown below using the following two swiftlint rules:

  • multiline_parameters_brackets
  • multiline_arguments_brackets
/* Don't use this */
func aVeryLongFunctionName(_ with: String, 
                           multiple: Int, 
                           parameters: [String]) -> Bool {
    // function body
}

/* Use this instead */
func aVeryLongFunctionName(
    _ with: String, 
    multiple: Int, 
    parameters: [String]
) -> Bool {
    // function body
}

/* or this if there is enough space horizontally */
func aVeryLongFunctionName(_ with: String, multiple: Int, parameters: [String]) -> Bool {
    // function body
}

I made no changes to the code apart from formatting and indenting the existing code

- enable `multiline_parameters_brackets` swiftlint rule
- enable `multiline_arguments_brackets` swiftlint rule
@Wouter01
Copy link
Member

Wouter01 commented Jan 14, 2023

Does this enforce the use of multi-line arguments, or can we still write single-line arguments?

@lukepistrol
Copy link
Member Author

lukepistrol commented Jan 14, 2023

Does this enforce the use of multi-line arguments, or can we still write single-line arguments?

You can still use single line arguments. This applies only to multiline arguments (e.g. when there are too many arguments to stay within the specified line length)

(updated the description)

Copy link
Member

@Wouter01 Wouter01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still use single line arguments. This applies only to multiline arguments (e.g. when there are too many arguments to stay within the specified line length)

Awesome!

Copy link
Contributor

@matthijseikelenboom matthijseikelenboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this looks better

@lukepistrol lukepistrol merged commit 1b6f521 into CodeEditApp:main Jan 14, 2023
@lukepistrol lukepistrol deleted the chore/code-style branch January 14, 2023 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants