Skip to content

Commit 81f9e42

Browse files
committed
Improve names of some existing options
1 parent 741604e commit 81f9e42

12 files changed

+145
-63
lines changed

Rules.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ Remove blank lines between consecutive guard statements, and insert a blank afte
306306

307307
Option | Description
308308
--- | ---
309-
`--linebtwnguards` | Insert line between guards: "true" or "false" (default)
309+
`--linebetweenguards` | Insert line between guards: "true" or "false" (default)
310310

311311
<details>
312312
<summary>Examples</summary>
313313

314-
`--linebtwnguards false` (default)
314+
`--linebetweenguards false` (default)
315315

316316
```diff
317317
// Multiline guard
@@ -338,7 +338,7 @@ Option | Description
338338
let doTheJob = nikekov()
339339
```
340340

341-
`--linebtwnguards true`
341+
`--linebetweenguards true`
342342

343343
```diff
344344
// Multiline guard
@@ -621,7 +621,7 @@ Assign properties using if / switch expressions.
621621

622622
Option | Description
623623
--- | ---
624-
`--condassignment` | Use cond. assignment: "after-property" (default) or "always"
624+
`--conditionalassignment` | Use if/switch expressions for conditional assignment: "after-property" (default) or "always"
625625

626626
<details>
627627
<summary>Examples</summary>
@@ -766,7 +766,7 @@ Use doc comments for API declarations, otherwise use regular comments.
766766

767767
Option | Description
768768
--- | ---
769-
`--doccomments` | Doc comments: "before-declarations" (default) or "preserve"
769+
`--doccomments` | Convert standard comments to doc comments: "before-declarations" (default) or "preserve"
770770

771771
<details>
772772
<summary>Examples</summary>
@@ -1152,7 +1152,7 @@ instead of type constraints (`extension Array where Element == Foo`).
11521152

11531153
Option | Description
11541154
--- | ---
1155-
`--generictypes` | Semicolon-delimited list of generic types and type parameters
1155+
`--generictypes` | Semicolon-delimited list of generic types and type parameters. For example: "LinkedList<Element>;StateStore<State, Action>"
11561156

11571157
<details>
11581158
<summary>Examples</summary>
@@ -1606,14 +1606,14 @@ Option | Description
16061606
`--structthreshold` | Minimum line count to organize struct body. Defaults to 0
16071607
`--classthreshold` | Minimum line count to organize class body. Defaults to 0
16081608
`--enumthreshold` | Minimum line count to organize enum body. Defaults to 0
1609-
`--extensionlength` | Minimum line count to organize extension body. Defaults to 0
1609+
`--extensionthreshold` | Minimum line count to organize extension body. Defaults to 0
16101610
`--organizationmode` | Organize declarations by "visibility" (default) or "type"
16111611
`--visibilityorder` | Order for visibility groups inside declaration
16121612
`--typeorder` | Order for declaration type groups inside declaration
16131613
`--visibilitymarks` | Marks for visibility groups (public:Public Fields,..)
16141614
`--typemarks` | Marks for declaration type groups (classMethod:Baaz,..)
16151615
`--groupblanklines` | Require a blank line after each subgroup. Default: true
1616-
`--sortswiftuiprops` | Sort SwiftUI props: none, alphabetize, first-appearance-sort
1616+
`--sortswiftuiproperties` | Sort SwiftUI props: "none", "alphabetize", "first-appearance-sort"
16171617

16181618
<details>
16191619
<summary>Examples</summary>
@@ -1762,8 +1762,8 @@ Convert functional `forEach` calls to for loops.
17621762

17631763
Option | Description
17641764
--- | ---
1765-
`--anonymousforeach` | Convert anonymous forEach: "convert" (default) or "ignore"
1766-
`--inlinedforeach` | Convert inline forEach to for: "convert", "ignore" (default)
1765+
`--anonymousforeach` | Convert anonymous forEach closures to for loops: "convert" (default) or "ignore"
1766+
`--singlelineforeach` | Convert single-line forEach closures to for loop: "convert", "ignore" (default)
17671767

17681768
<details>
17691769
<summary>Examples</summary>
@@ -1919,7 +1919,7 @@ Option | Description
19191919
--- | ---
19201920
`--propertytypes` | "inferred", "explicit", or "infer-locals-only" (default)
19211921
`--inferredtypes` | "exclude-cond-exprs" (default) or "always"
1922-
`--preservedsymbols` | Comma-delimited list of symbols to be ignored by the rule
1922+
`--preservedpropertytypes` | Comma-delimited list of symbols to be ignored and preserved as-is by the propertyTypes rule
19231923

19241924
<details>
19251925
<summary>Examples</summary>
@@ -3427,10 +3427,10 @@ Option | Description
34273427
--- | ---
34283428
`--funcattributes` | Function @attributes: "preserve", "prev-line", or "same-line"
34293429
`--typeattributes` | Type @attributes: "preserve", "prev-line", or "same-line"
3430-
`--storedvarattrs` | Stored var @attribs: "preserve", "prev-line", or "same-line"
3431-
`--computedvarattrs` | Computed var @attribs: "preserve", "prev-line", "same-line"
3432-
`--complexattrs` | Complex @attributes: "preserve", "prev-line", or "same-line"
3433-
`--noncomplexattrs` | List of @attributes to exclude from complexattrs rule
3430+
`--storedvarattributes` | Stored var @attributes: "preserve", "prev-line", or "same-line"
3431+
`--computedvarattributes` | Computed var @attributes: "preserve", "prev-line", "same-line"
3432+
`--complexattributes` | Complex @attributes: "preserve", "prev-line", or "same-line"
3433+
`--noncomplexattributes` | List of @attributes to exclude from --complexattributes options
34343434

34353435
<details>
34363436
<summary>Examples</summary>

Sources/OptionDescriptor.swift

Lines changed: 93 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class OptionDescriptor {
9393
trueValues: [String],
9494
falseValues: [String])
9595
{
96-
assert(argumentName.count <= Options.maxArgumentNameLength)
9796
assert(argumentName == argumentName.lowercased())
9897
self.argumentName = argumentName
9998
self.displayName = displayName
@@ -968,7 +967,7 @@ struct _Descriptors {
968967
keyPath: \.organizeEnumThreshold
969968
)
970969
let organizeExtensionThreshold = OptionDescriptor(
971-
argumentName: "extensionlength",
970+
argumentName: "extensionthreshold",
972971
displayName: "Organize Extension Threshold",
973972
help: "Minimum line count to organize extension body. Defaults to 0",
974973
keyPath: \.organizeExtensionThreshold
@@ -1068,27 +1067,27 @@ struct _Descriptors {
10681067
keyPath: \.typeAttributes
10691068
)
10701069
let storedVarAttributes = OptionDescriptor(
1071-
argumentName: "storedvarattrs",
1070+
argumentName: "storedvarattributes",
10721071
displayName: "Stored Property Attributes",
1073-
help: "Stored var @attribs: \"preserve\", \"prev-line\", or \"same-line\"",
1072+
help: "Stored var @attributes: \"preserve\", \"prev-line\", or \"same-line\"",
10741073
keyPath: \.storedVarAttributes
10751074
)
10761075
let computedVarAttributes = OptionDescriptor(
1077-
argumentName: "computedvarattrs",
1076+
argumentName: "computedvarattributes",
10781077
displayName: "Computed Property Attributes",
1079-
help: "Computed var @attribs: \"preserve\", \"prev-line\", \"same-line\"",
1078+
help: "Computed var @attributes: \"preserve\", \"prev-line\", \"same-line\"",
10801079
keyPath: \.computedVarAttributes
10811080
)
10821081
let complexAttributes = OptionDescriptor(
1083-
argumentName: "complexattrs",
1082+
argumentName: "complexattributes",
10841083
displayName: "Complex Attributes",
10851084
help: "Complex @attributes: \"preserve\", \"prev-line\", or \"same-line\"",
10861085
keyPath: \.complexAttributes
10871086
)
10881087
let complexAttributesExceptions = OptionDescriptor(
1089-
argumentName: "noncomplexattrs",
1088+
argumentName: "noncomplexattributes",
10901089
displayName: "Complex Attribute exceptions",
1091-
help: "List of @attributes to exclude from complexattrs rule",
1090+
help: "List of @attributes to exclude from --complexattributes options",
10921091
keyPath: \.complexAttributesExceptions
10931092
)
10941093
let yodaSwap = OptionDescriptor(
@@ -1166,7 +1165,7 @@ struct _Descriptors {
11661165
let genericTypes = OptionDescriptor(
11671166
argumentName: "generictypes",
11681167
displayName: "Additional generic types",
1169-
help: "Semicolon-delimited list of generic types and type parameters",
1168+
help: "Semicolon-delimited list of generic types and type parameters. For example: \"LinkedList<Element>;StateStore<State, Action>\"",
11701169
keyPath: \.genericTypes,
11711170
fromArgument: { $0 },
11721171
toArgument: { $0 }
@@ -1182,31 +1181,31 @@ struct _Descriptors {
11821181
let preserveAnonymousForEach = OptionDescriptor(
11831182
argumentName: "anonymousforeach",
11841183
displayName: "Anonymous forEach closures",
1185-
help: "Convert anonymous forEach: \"convert\" (default) or \"ignore\"",
1184+
help: "Convert anonymous forEach closures to for loops: \"convert\" (default) or \"ignore\"",
11861185
keyPath: \.preserveAnonymousForEach,
11871186
trueValues: ["ignore", "preserve"],
11881187
falseValues: ["convert"]
11891188
)
11901189
let preserveSingleLineForEach = OptionDescriptor(
1191-
argumentName: "inlinedforeach",
1192-
displayName: "Inlined forEach closures",
1193-
help: "Convert inline forEach to for: \"convert\", \"ignore\" (default)",
1190+
argumentName: "singlelineforeach",
1191+
displayName: "Single-line forEach closures",
1192+
help: "Convert single-line forEach closures to for loop: \"convert\", \"ignore\" (default)",
11941193
keyPath: \.preserveSingleLineForEach,
11951194
trueValues: ["ignore", "preserve"],
11961195
falseValues: ["convert"]
11971196
)
11981197
let preserveDocComments = OptionDescriptor(
11991198
argumentName: "doccomments",
12001199
displayName: "Doc comments",
1201-
help: "Doc comments: \"before-declarations\" (default) or \"preserve\"",
1200+
help: "Convert standard comments to doc comments: \"before-declarations\" (default) or \"preserve\"",
12021201
keyPath: \.preserveDocComments,
12031202
trueValues: ["preserve"],
12041203
falseValues: ["before-declarations", "declarations"]
12051204
)
12061205
let conditionalAssignmentOnlyAfterNewProperties = OptionDescriptor(
1207-
argumentName: "condassignment",
1206+
argumentName: "conditionalassignment",
12081207
displayName: "Apply conditionalAssignment rule",
1209-
help: "Use cond. assignment: \"after-property\" (default) or \"always\"",
1208+
help: "Use if/switch expressions for conditional assignment: \"after-property\" (default) or \"always\"",
12101209
keyPath: \.conditionalAssignmentOnlyAfterNewProperties,
12111210
trueValues: ["after-property"],
12121211
falseValues: ["always"]
@@ -1247,11 +1246,11 @@ struct _Descriptors {
12471246
help: "Comma separated list of declaration names to exclude",
12481247
keyPath: \.preservedPrivateDeclarations
12491248
)
1250-
let preservedSymbols = OptionDescriptor(
1251-
argumentName: "preservedsymbols",
1252-
displayName: "Preserved Symbols",
1253-
help: "Comma-delimited list of symbols to be ignored by the rule",
1254-
keyPath: \.preservedSymbols
1249+
let preservedPropertyTypes = OptionDescriptor(
1250+
argumentName: "preservedpropertytypes",
1251+
displayName: "Preserved Property Types",
1252+
help: "Comma-delimited list of symbols to be ignored and preserved as-is by the propertyTypes rule",
1253+
keyPath: \.preservedPropertyTypes
12551254
)
12561255
let additionalXCTestSymbols = OptionDescriptor(
12571256
argumentName: "xctestsymbols",
@@ -1260,9 +1259,9 @@ struct _Descriptors {
12601259
keyPath: \.additionalXCTestSymbols
12611260
)
12621261
let swiftUIPropertiesSortMode = OptionDescriptor(
1263-
argumentName: "sortswiftuiprops",
1262+
argumentName: "sortswiftuiproperties",
12641263
displayName: "Sort SwiftUI Dynamic Properties",
1265-
help: "Sort SwiftUI props: none, alphabetize, first-appearance-sort",
1264+
help: "Sort SwiftUI props: \"none\", \"alphabetize\", \"first-appearance-sort\"",
12661265
keyPath: \.swiftUIPropertiesSortMode
12671266
)
12681267
let equatableMacro = OptionDescriptor(
@@ -1280,7 +1279,7 @@ struct _Descriptors {
12801279
falseValues: ["#fileID", "fileID"]
12811280
)
12821281
let lineBetweenConsecutiveGuards = OptionDescriptor(
1283-
argumentName: "linebtwnguards",
1282+
argumentName: "linebetweenguards",
12841283
displayName: "Blank Line Between Consecutive Guards",
12851284
help: "Insert line between guards: \"true\" or \"false\" (default)",
12861285
keyPath: \.lineBetweenConsecutiveGuards,
@@ -1361,7 +1360,7 @@ struct _Descriptors {
13611360
argumentName: "varattributes",
13621361
displayName: "Var Attributes",
13631362
help: "Property @attributes: \"preserve\", \"prev-line\", or \"same-line\"",
1364-
deprecationMessage: "Use with `--storedvarattrs` or `--computedvarattrs` instead.",
1363+
deprecationMessage: "Use with `--storedvarattributes` or `--computedvarattributes` instead.",
13651364
keyPath: \.varAttributes
13661365
)
13671366

@@ -1411,12 +1410,79 @@ struct _Descriptors {
14111410
keyPath: \.preserveSingleLineForEach,
14121411
trueValues: ["ignore", "preserve"],
14131412
falseValues: ["convert"]
1414-
).renamed(to: "inlinedforeach")
1413+
).renamed(to: "singlelineforeach")
14151414

14161415
let redundantType = OptionDescriptor(
14171416
argumentName: "redundanttype",
14181417
displayName: "Redundant Type",
14191418
help: "deprecated",
14201419
keyPath: \.propertyTypes
14211420
).renamed(to: "propertytypes")
1421+
1422+
let inlinedForEach = OptionDescriptor(
1423+
argumentName: "inlinedforeach",
1424+
displayName: "Inlined forEach closures",
1425+
help: "deprecated",
1426+
keyPath: \.preserveSingleLineForEach,
1427+
trueValues: ["ignore", "preserve"],
1428+
falseValues: ["convert"]
1429+
).renamed(to: "singlelineforeach")
1430+
1431+
let condAssignment = OptionDescriptor(
1432+
argumentName: "condassignment",
1433+
displayName: "Apply conditionalAssignment rule",
1434+
help: "deprecated",
1435+
keyPath: \.conditionalAssignmentOnlyAfterNewProperties,
1436+
trueValues: ["after-property"],
1437+
falseValues: ["always"]
1438+
).renamed(to: "conditionalassignment")
1439+
1440+
let storedVarAttrs = OptionDescriptor(
1441+
argumentName: "storedvarattrs",
1442+
displayName: "Stored Property Attributes",
1443+
help: "deprecated",
1444+
keyPath: \.storedVarAttributes
1445+
).renamed(to: "storedvarattributes")
1446+
1447+
let computedVarAttrs = OptionDescriptor(
1448+
argumentName: "computedvarattrs",
1449+
displayName: "Computed Property Attributes",
1450+
help: "deprecated",
1451+
keyPath: \.computedVarAttributes
1452+
).renamed(to: "computedvarattributes")
1453+
1454+
let complexAttrs = OptionDescriptor(
1455+
argumentName: "complexattrs",
1456+
displayName: "Complex Attributes",
1457+
help: "deprecated",
1458+
keyPath: \.complexAttributes
1459+
).renamed(to: "complexattributes")
1460+
1461+
let complexAttrsExceptions = OptionDescriptor(
1462+
argumentName: "noncomplexattrs",
1463+
displayName: "Complex Attribute exceptions",
1464+
help: "deprecated",
1465+
keyPath: \.complexAttributesExceptions
1466+
).renamed(to: "noncomplexattributes")
1467+
1468+
let preservedSymbols = OptionDescriptor(
1469+
argumentName: "preservedsymbols",
1470+
displayName: "Preserved Symbols",
1471+
help: "deprecated",
1472+
keyPath: \.preservedPropertyTypes
1473+
).renamed(to: "preservedpropertytypes")
1474+
1475+
let swiftUIPropsSortMode = OptionDescriptor(
1476+
argumentName: "sortswiftuiprops",
1477+
displayName: "Sort SwiftUI Dynamic Properties",
1478+
help: "deprecated",
1479+
keyPath: \.swiftUIPropertiesSortMode
1480+
).renamed(to: "sortswiftuiproperties")
1481+
1482+
let organizeExtensionLength = OptionDescriptor(
1483+
argumentName: "extensionlength",
1484+
displayName: "Organize Extension Threshold",
1485+
help: "deprecated",
1486+
keyPath: \.organizeExtensionThreshold
1487+
).renamed(to: "extensionthreshold")
14221488
}

Sources/Options.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ public struct FormatOptions: CustomStringConvertible {
723723
public var yodaSwap: YodaMode
724724
public var extensionACLPlacement: ExtensionACLPlacement
725725
public var propertyTypes: PropertyTypes
726-
public var preservedSymbols: Set<String>
726+
public var preservedPropertyTypes: Set<String>
727727
public var inferredTypesInConditionalExpressions: Bool
728728
public var emptyBracesSpacing: EmptyBracesSpacing
729729
public var acronyms: Set<String>
@@ -855,7 +855,7 @@ public struct FormatOptions: CustomStringConvertible {
855855
yodaSwap: YodaMode = .always,
856856
extensionACLPlacement: ExtensionACLPlacement = .onExtension,
857857
propertyTypes: PropertyTypes = .inferLocalsOnly,
858-
preservedSymbols: Set<String> = ["Package"],
858+
preservedPropertyTypes: Set<String> = ["Package"],
859859
inferredTypesInConditionalExpressions: Bool = false,
860860
emptyBracesSpacing: EmptyBracesSpacing = .noSpace,
861861
acronyms: Set<String> = ["ID", "URL", "UUID"],
@@ -977,7 +977,7 @@ public struct FormatOptions: CustomStringConvertible {
977977
self.yodaSwap = yodaSwap
978978
self.extensionACLPlacement = extensionACLPlacement
979979
self.propertyTypes = propertyTypes
980-
self.preservedSymbols = preservedSymbols
980+
self.preservedPropertyTypes = preservedPropertyTypes
981981
self.inferredTypesInConditionalExpressions = inferredTypesInConditionalExpressions
982982
self.emptyBracesSpacing = emptyBracesSpacing
983983
self.acronyms = acronyms

Sources/Rules/BlankLinesAfterGuardStatements.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public extension FormatRule {
77
static let blankLinesAfterGuardStatements = FormatRule(
88
help: "Remove blank lines between consecutive guard statements, and insert a blank after the last guard statement.",
99
disabledByDefault: true,
10-
options: ["linebtwnguards"]
10+
options: ["linebetweenguards"]
1111
) { formatter in
1212
formatter.forEach(.keyword("guard")) { guardIndex, _ in
1313
guard var elseIndex = formatter.index(of: .keyword("else"), after: guardIndex) else {
@@ -47,7 +47,7 @@ public extension FormatRule {
4747
}
4848
} examples: {
4949
"""
50-
`--linebtwnguards false` (default)
50+
`--linebetweenguards false` (default)
5151
5252
```diff
5353
// Multiline guard
@@ -74,7 +74,7 @@ public extension FormatRule {
7474
let doTheJob = nikekov()
7575
```
7676
77-
`--linebtwnguards true`
77+
`--linebetweenguards true`
7878
7979
```diff
8080
// Multiline guard

Sources/Rules/ConditionalAssignment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public extension FormatRule {
1212
static let conditionalAssignment = FormatRule(
1313
help: "Assign properties using if / switch expressions.",
1414
orderAfter: [.redundantReturn],
15-
options: ["condassignment"]
15+
options: ["conditionalassignment"]
1616
) { formatter in
1717
// If / switch expressions were added in Swift 5.9 (SE-0380)
1818
guard formatter.options.swiftVersion >= "5.9" else {

0 commit comments

Comments
 (0)