Skip to content

Should we lint and format code of swift-format with swift-format? #610

Open
@natikgadzhi

Description

@natikgadzhi

I was working on a prototype for #607 and noticed a few lines with trailing spaces here and there, and thought I'd check for formatting rules. Apologies if I missed this in contributing docs, but it seems that:

  • The repository is not using any formatting tool explicitly
  • No .swift-format configuration in particular
  • No formatting preference documented in CONTRIBUTING.md or Documentation/Development.md
  • There is Scripts/format-diff.sh[Scripts/format-diff.sh], though, but I don't know if it's hooked up in a CI (and no GitHub CI checks are set up, seemingly?)

How are we doing now?

I tried running the default configuration, and swift-format is a bit angry with itself:

There are 266 offenses:
$ swift-format lint --recursive Sources
Sources/SwiftFormatConfiguration/Configuration.swift:222:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormatConfiguration/Configuration.swift:237:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormatConfiguration/Configuration.swift:261:1: warning: [LineLength] line is too long
Sources/SwiftFormatConfiguration/Configuration.swift:263:1: warning: [LineLength] line is too long
Sources/SwiftFormatConfiguration/Configuration.swift:264:1: warning: [LineLength] line is too long
Sources/SwiftFormatConfiguration/Configuration.swift:265:1: warning: [LineLength] line is too long
Sources/swift-format/Frontend/LintFrontend.swift:36:29: warning: [AddLines] add 1 line break
Sources/swift-format/Frontend/LintFrontend.swift:37:1: warning: [Indentation] unindent by 2 spaces
Sources/swift-format/Frontend/LintFrontend.swift:38:1: warning: [Indentation] unindent by 2 spaces
Sources/swift-format/Frontend/LintFrontend.swift:39:1: warning: [Indentation] unindent by 2 spaces
Sources/swift-format/Frontend/LintFrontend.swift:40:1: warning: [Indentation] unindent by 2 spaces
Sources/swift-format/Frontend/LintFrontend.swift:41:1: warning: [Indentation] unindent by 2 spaces
Sources/swift-format/Frontend/Frontend.swift:17:1: warning: [OrderedImports] sort import statements lexicographically
Sources/swift-format/Frontend/Frontend.swift:112:10: warning: [AddLines] add 1 line break
Sources/swift-format/Frontend/Frontend.swift:113:1: warning: [Indentation] indent by 2 spaces
Sources/swift-format/Frontend/Frontend.swift:114:1: warning: [Indentation] indent by 2 spaces
Sources/swift-format/Frontend/Frontend.swift:194:1: warning: [LineLength] line is too long
Sources/swift-format/Frontend/FormatFrontend.swift:43:77: warning: [ReturnVoidInsteadOfEmptyTuple] replace '()' with 'Void'
Sources/swift-format/Subcommands/LintFormatOptions.swift:46:9: warning: [AddLines] add 1 line break
Sources/swift-format/Subcommands/LintFormatOptions.swift:47:1: warning: [Indentation] indent by 2 spaces
Sources/swift-format/Subcommands/LintFormatOptions.swift:48:1: warning: [Indentation] indent by 2 spaces
Sources/swift-format/Subcommands/LintFormatOptions.swift:49:1: warning: [Indentation] indent by 2 spaces
Sources/swift-format/Utilities/DiagnosticsEngine.swift:15:1: warning: [OrderedImports] sort import statements lexicographically
Sources/swift-format/Utilities/FormatError.swift:23:2: warning: [RemoveLine] remove line break
Sources/swift-format/Utilities/FileIterator.swift:101:15: warning: [AddLines] add 1 line break
Sources/swift-format/Utilities/FileIterator.swift:101:21: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/Verbatim.swift:118:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:293:10: warning: [NoParensAroundConditions] remove the parentheses around this expression
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:293:10: warning: [NoParensAroundConditions] remove the parentheses around this expression
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:293:10: warning: [NoParensAroundConditions] remove the parentheses around this expression
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:147:18: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:334:40: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:358:34: warning: [RemoveLine] remove line break
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:359:12: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:410:42: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/PrettyPrint.swift:415:40: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:31:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3969:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:4002:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:4016:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:18:1: warning: [NoAccessLevelOnExtensionDeclaration] move this 'fileprivate' access modifier to precede each member inside this extension
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:21:3: note: add 'fileprivate' access modifier to this declaration
/Users/nategadzhi/src/apple/swift-format/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1136:76: warning: [TrailingComma] remove trailing comma from the last element in single line collection literal
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:19:75: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:237:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:329:31: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:354:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:391:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:394:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:506:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:531:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:567:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:568:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:586:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:593:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:604:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:605:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:644:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:664:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:665:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:698:30: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:707:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:708:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:733:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:787:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:801:100: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1037:100: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1038:100: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1038:131: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1040:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1215:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1223:15: warning: [Spacing] remove 1 space
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1234:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1271:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1424:75: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1425:64: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1426:77: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1476:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1503:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1545:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1632:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1646:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1646:62: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:1848:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2418:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2489:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2490:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2518:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2599:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:2980:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3033:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3033:8: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3148:31: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3148:34: warning: [RemoveLine] remove line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3518:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3523:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3636:40: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3636:48: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3637:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3638:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3638:7: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3665:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3666:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3707:1: warning: [LineLength] line is too long
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3757:38: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3757:41: warning: [RemoveLine] remove line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3758:74: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3842:49: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3842:52: warning: [RemoveLine] remove line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3843:65: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3973:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:3974:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:4024:16: warning: [Spacing] add 1 space
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:4061:62: warning: [Spacing] remove 1 space
Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift:4062:63: warning: [Spacing] remove 1 space
Sources/SwiftFormat/PrettyPrint/WhitespaceLinter.swift:327:10: warning: [AddLines] add 1 line break
Sources/SwiftFormat/PrettyPrint/WhitespaceLinter.swift:328:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Core/LegacyTriviaBehavior.swift:29:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Core/FormatPipeline.swift:29:3: warning: [UseSynthesizedInitializer] remove this explicit initializer, which is identical to the compiler-synthesized initializer
Sources/SwiftFormat/Core/DocumentationCommentText.swift:70:7: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Core/DocumentationCommentText.swift:72:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:73:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:74:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:75:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:76:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:77:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:78:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:79:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/DocumentationCommentText.swift:80:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/RuleNameCache+Generated.swift:18:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Core/RuleNameCache+Generated.swift:21:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Core/RuleNameCache+Generated.swift:30:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Core/RuleNameCache+Generated.swift:53:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Core/RuleMask.swift:95:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Core/Context.swift:17:1: warning: [OrderedImports] sort import statements lexicographically
Sources/SwiftFormat/Core/Rule.swift:64:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/Rule.swift:65:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/Rule.swift:66:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/Rule.swift:67:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Core/Trivia+Convenience.swift:50:21: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Core/Trivia+Convenience.swift:51:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Core/Trivia+Convenience.swift:52:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Core/Trivia+Convenience.swift:53:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Core/Trivia+Convenience.swift:54:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Core/AddModifierRewriter.swift:15:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Core/DocumentationComment.swift:278:1: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:61:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:143:97: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:186:27: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:191:36: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:191:44: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:192:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/NoCasesWithOnlyFallthrough.swift:196:1: warning: [LineLength] line is too long
/Users/nategadzhi/src/apple/swift-format/Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:278:76: warning: [TrailingComma] remove trailing comma from the last element in single line collection literal
/Users/nategadzhi/src/apple/swift-format/Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:304:28: warning: [TrailingComma] remove trailing comma from the last element in single line collection literal
Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:96:28: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:96:52: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:181:28: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:181:52: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/Rules/UseShorthandTypeNames.swift:557:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:38:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:38:71: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:66:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:66:71: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:83:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/ReturnVoidInsteadOfEmptyTuple.swift:102:95: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/TypeNamesShouldBeCapitalized.swift:19:48: warning: [Spacing] remove 1 space
Sources/SwiftFormat/Rules/TypeNamesShouldBeCapitalized.swift:62:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/Rules/TypeNamesShouldBeCapitalized.swift:62:51: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:194:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:209:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:70:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:128:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:129:8: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:129:21: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:213:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/UseSynthesizedInitializer.swift:216:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/UseWhereClausesInForLoops.swift:97:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/UseWhereClausesInForLoops.swift:58:1: warning: [Indentation] unindent by 2 spaces
Sources/SwiftFormat/Rules/UseWhereClausesInForLoops.swift:108:42: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoVoidReturnOnFunctionSignature.swift:27:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NoVoidReturnOnFunctionSignature.swift:31:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift:143:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift:157:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/ValidateDocumentationComments.swift:110:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/Rules/OneCasePerLine.swift:93:96: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/GroupNumericLiterals.swift:62:28: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NeverUseImplicitlyUnwrappedOptionals.swift:44:97: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NeverUseImplicitlyUnwrappedOptionals.swift:44:116: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NeverUseImplicitlyUnwrappedOptionals.swift:60:95: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:37:27: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:38:32: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:102:22: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:103:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:104:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:104:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift:105:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/AllPublicDeclarationsHaveDocumentation.swift:54:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NoLabelsInCasePatterns.swift:53:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:59:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:65:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:71:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:77:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:83:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:89:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FileScopedDeclarationPrivacy.swift:95:25: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OrderedImports.swift:262:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/OrderedImports.swift:269:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/OrderedImports.swift:286:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/OrderedImports.swift:352:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/OrderedImports.swift:421:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/OrderedImports.swift:135:20: warning: [TrailingWhitespace] remove trailing whitespace
Sources/SwiftFormat/Rules/OneVariableDeclarationPerLine.swift:205:2: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/FullyIndirectEnum.swift:92:14: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/FullyIndirectEnum.swift:93:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/FullyIndirectEnum.swift:94:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/FullyIndirectEnum.swift:94:10: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/DontRepeatTypeInStaticProperties.swift:68:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/AlwaysUseLowerCamelCase.swift:189:1: warning: [FileScopedDeclarationPrivacy] replace 'fileprivate' with 'private' on file-scoped declarations
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:19:45: warning: [Spacing] remove 1 space
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:23:62: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:23:65: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:24:48: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:33:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift:33:39: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoAssignmentInExpressions.swift:68:72: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/NoAssignmentInExpressions.swift:124:10: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:30:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:31:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:31:65: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:44:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:45:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:46:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:47:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:47:66: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:59:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:59:66: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:72:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:72:72: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:73:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:81:100: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:86:12: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:87:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:88:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:88:15: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:93:1: warning: [Indentation] unindent by 4 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:93:67: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:97:12: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:98:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:99:1: warning: [Indentation] indent by 2 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:99:9: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:126:1: warning: [Indentation] unindent by 1 spaces
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:126:63: warning: [AddLines] add 1 line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:126:68: warning: [RemoveLine] remove line break
Sources/SwiftFormat/Rules/OmitExplicitReturns.swift:131:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NeverForceUnwrap.swift:37:1: warning: [LineLength] line is too long
Sources/SwiftFormat/Rules/NeverForceUnwrap.swift:47:1: warning: [LineLength] line is too long
Sources/_SwiftFormatTestSupport/DiagnosingTestCase.swift:5:1: warning: [OrderedImports] sort import statements lexicographically
Sources/_SwiftFormatTestSupport/MarkedText.swift:54:1: warning: [LineLength] line is too long
Sources/generate-pipeline/RuleCollector.swift:15:1: warning: [OrderedImports] sort import statements lexicographically
Sources/generate-pipeline/main.swift:19:21: warning: [AddLines] add 1 line break
Sources/generate-pipeline/main.swift:22:19: warning: [AddLines] add 1 line break
Sources/generate-pipeline/main.swift:26:23: warning: [AddLines] add 1 line break
Sources/generate-pipeline/main.swift:30:24: warning: [AddLines] add 1 line break
Sources/generate-pipeline/RuleNameCacheGenerator.swift:51:1: warning: [LineLength] line is too long
Sources/generate-pipeline/RuleNameCacheGenerator.swift:55:2: warning: [RemoveLine] remove line break

What should we do about it?

  • Most SSWG projects use nicklockwood/SwiftFormat, but swift-syntax uses swift-format and indents with two spaces — I'm in the beginner league, and not sure how that will evolve long-term, but it does seem reasonable to suggest using swift-format for this repo source code?
  • We can adopt https://github.com/apple/swift-syntax/blob/main/format.py script from swift-syntax, and perhaps use consistent .swift-format rules as well — their config is pretty minimal.

Why bother at all?

I get an itch to commit those formatting cleanups, but as they are not related to a particular issue I'm working on, they're distracting for myself and for folks who would review my code. It's probably a good idea to clean them up in a single pass. Plus, that will make swift-format consistent with swift-syntax for both ourselves, and community contributors like myself.

TODOs

If generally adding formatting and linting to CI seems like a good idea, and if we confirm that swift-syntax format.py is a good starting point, then:

  • We should set up the formatting script in the repository, run it, and get the cleanup PR merged in.
  • We should update Documentation/Development.md and CONTRIBUTING.md to mention them.
  • Could we also set up the CI?

I'm happy to help in any way I can — and can start with the first two items on this list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions