SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Clarify documentation for multiline_arguments_brackets and multiline_literal_brackets

Open chrisjf opened this issue 1 year ago β€’ 1 comments

New Issue Checklist

Describe the bug

Hello SwiftLint Team!

I have a documentation improvement request. Today, my coworkers and I were reviewing the documentation for two rules multiline_arguments_brackets and multiline_literal_brackets and we thought it could be improved by including the following triggering examples.

The reason I am requesting these triggering examples be included in the documentation is because they are a common style, and it's not immediately obvious from the rule definitions whether these examples would trigger or not. We ended up wasting time making a sample project and integrating SwiftLint, just to figure out if these two examples would trigger or not. So to avoid future lost person-hours, I propose this documentation improvement! πŸ˜„

Thanks, Chris

multiline_arguments_brackets

Existing documentation: https://realm.github.io/SwiftLint/multiline_arguments_brackets.html

// Triggering Example
foo(↓param1: "Param1",
    param2: "Param2",
    param3: "Param3"↓)

multiline_literal_brackets

Existing documentation: https://realm.github.io/SwiftLint/multiline_literal_brackets.html

// Triggering Example
let houseCup = [↓"gryffinder": 460,
		"hufflepuff": 370,
		"ravenclaw": 410,
		"slytherin": 450↓]

I have attached a screenshot and a sample project showing that the above two examples are indeed triggering. Screen Shot 2022-08-01 Sample Project: SwiftLintTest.zip


P.s. If you'd like me to make a pull request to update the documentation, would you kindly confirm how I could do so? I don't see a central location for the documentation in the repository. I wonder if the documentation is generated from those RuleDescription objects in the code? For example: https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/Style/MultilineLiteralBracketsRule.swift

chrisjf avatar Aug 01 '22 23:08 chrisjf

You are exactly right. The examples are listed in the RuleDescription of every rule. They will be used in the documentation of the rule. Furthermore, they are automatically tested. Feel free to create a PR!

SimplyDanny avatar Aug 02 '22 16:08 SimplyDanny

Thanks for the info @SimplyDanny. I have made a new PR: https://github.com/realm/SwiftLint/pull/4098 πŸ™‚

chrisjf avatar Aug 15 '22 23:08 chrisjf