Skip to content

Commit

Permalink
Group rules in Rules.md by default status
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Mar 6, 2022
1 parent f985667 commit 40bff9e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
30 changes: 18 additions & 12 deletions Rules.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Rules
# Default Rules (enabled by default)

* [acronyms](#acronyms)
* [andOperator](#andOperator)
* [anyObjectProtocol](#anyObjectProtocol)
* [assertionFailures](#assertionFailures)
* [blankLinesAroundMark](#blankLinesAroundMark)
* [blankLinesAtEndOfScope](#blankLinesAtEndOfScope)
* [blankLinesAtStartOfScope](#blankLinesAtStartOfScope)
* [blankLinesBetweenImports](#blankLinesBetweenImports)
* [blankLinesBetweenScopes](#blankLinesBetweenScopes)
* [blockComments](#blockComments)
* [braces](#braces)
* [consecutiveBlankLines](#consecutiveBlankLines)
* [consecutiveSpaces](#consecutiveSpaces)
Expand All @@ -22,15 +19,11 @@
* [hoistPatternLet](#hoistPatternLet)
* [indent](#indent)
* [initCoderUnavailable](#initCoderUnavailable)
* [isEmpty](#isEmpty)
* [leadingDelimiters](#leadingDelimiters)
* [linebreakAtEndOfFile](#linebreakAtEndOfFile)
* [linebreaks](#linebreaks)
* [markTypes](#markTypes)
* [modifierOrder](#modifierOrder)
* [numberFormatting](#numberFormatting)
* [organizeDeclarations](#organizeDeclarations)
* [preferDouble](#preferDouble)
* [preferKeyPath](#preferKeyPath)
* [redundantBackticks](#redundantBackticks)
* [redundantBreak](#redundantBreak)
Expand All @@ -53,7 +46,6 @@
* [semicolons](#semicolons)
* [sortDeclarations](#sortDeclarations)
* [sortedImports](#sortedImports)
* [sortedSwitchCases](#sortedSwitchCases)
* [spaceAroundBraces](#spaceAroundBraces)
* [spaceAroundBrackets](#spaceAroundBrackets)
* [spaceAroundComments](#spaceAroundComments)
Expand All @@ -65,7 +57,6 @@
* [spaceInsideComments](#spaceInsideComments)
* [spaceInsideGenerics](#spaceInsideGenerics)
* [spaceInsideParens](#spaceInsideParens)
* [specifiers *(deprecated)*](#specifiers)
* [strongOutlets](#strongOutlets)
* [strongifiedSelf](#strongifiedSelf)
* [todos](#todos)
Expand All @@ -78,11 +69,26 @@
* [wrap](#wrap)
* [wrapArguments](#wrapArguments)
* [wrapAttributes](#wrapAttributes)
* [wrapMultilineStatementBraces](#wrapMultilineStatementBraces)
* [yodaConditions](#yodaConditions)

# Opt-in Rules (disabled by default)

* [acronyms](#acronyms)
* [blankLinesBetweenImports](#blankLinesBetweenImports)
* [blockComments](#blockComments)
* [isEmpty](#isEmpty)
* [markTypes](#markTypes)
* [organizeDeclarations](#organizeDeclarations)
* [preferDouble](#preferDouble)
* [sortedSwitchCases](#sortedSwitchCases)
* [wrapConditionalBodies](#wrapConditionalBodies)
* [wrapEnumCases](#wrapEnumCases)
* [wrapMultilineStatementBraces](#wrapMultilineStatementBraces)
* [wrapSwitchCases](#wrapSwitchCases)
* [yodaConditions](#yodaConditions)

# Deprecated Rules (do not use)

* [specifiers](#specifiers)

----------

Expand Down
24 changes: 20 additions & 4 deletions Tests/MetadataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,27 @@ class MetadataTests: XCTestCase {

// NOTE: if test fails, just run it again locally to update rules file
func testGenerateRulesDocumentation() throws {
var result = "# Rules\n"
for rule in FormatRules.all {
let annotation = rule.isDeprecated ? " *(deprecated)*" : ""
result += "\n* [\(rule.name)\(annotation)](#\(rule.name))"
var result = "# Default Rules (enabled by default)\n"
for rule in FormatRules.default {
result += "\n* [\(rule.name)](#\(rule.name))"
}

result += "\n\n# Opt-in Rules (disabled by default)\n"
for rule in FormatRules.named(FormatRules.disabledByDefault) {
guard !rule.isDeprecated else {
continue
}
result += "\n* [\(rule.name)](#\(rule.name))"
}

let deprecatedRules = FormatRules.all.filter { $0.isDeprecated }
if !deprecatedRules.isEmpty {
result += "\n\n# Deprecated Rules (do not use)\n"
for rule in deprecatedRules {
result += "\n* [\(rule.name)](#\(rule.name))"
}
}

result += "\n\n----------"
for rule in FormatRules.all {
result += "\n\n## \(rule.name)\n\n\(rule.help)"
Expand Down

0 comments on commit 40bff9e

Please sign in to comment.