diff --git a/Plugins/LintPlugin/plugin.swift b/Plugins/LintPlugin/plugin.swift index b5563a5bb..4dd72204f 100644 --- a/Plugins/LintPlugin/plugin.swift +++ b/Plugins/LintPlugin/plugin.swift @@ -20,7 +20,7 @@ struct LintPlugin { process.waitUntilExit() if process.terminationReason == .exit && process.terminationStatus == 0 { - print("Lintted the source code.") + print("Linted the source code.") } else { let problem = "\(process.terminationReason):\(process.terminationStatus)" diff --git a/README.md b/README.md index 891b9370c..c66c94d64 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ want to do. Once the build has finished, the `swift-format` executable will be located at `.build/release/swift-format`. -To test that the formatter was built succesfully and is compatible with your +To test that the formatter was built successfully and is compatible with your Swift toolchain, you can also run the following command: ```sh diff --git a/Sources/SwiftFormatPrettyPrint/PrettyPrint.swift b/Sources/SwiftFormatPrettyPrint/PrettyPrint.swift index 75ce5b034..a85173487 100644 --- a/Sources/SwiftFormatPrettyPrint/PrettyPrint.swift +++ b/Sources/SwiftFormatPrettyPrint/PrettyPrint.swift @@ -186,7 +186,7 @@ public class PrettyPrinter { outputBuffer.append(String(str)) } - /// Writes newlines into the output stream, taking into account any pre-existing consecutive + /// Writes newlines into the output stream, taking into account any preexisting consecutive /// newlines and the maximum allowed number of blank lines. /// /// This function does some implicit collapsing of consecutive newlines to ensure that the @@ -248,7 +248,7 @@ public class PrettyPrinter { /// Print out the provided token, and apply line-wrapping and indentation as needed. /// /// This method takes a Token and it's length, and it keeps track of how much space is left on the - /// current line it is printing on. If a token exceeds the remaning space, we break to a new line, + /// current line it is printing on. If a token exceeds the remaining space, we break to a new line, /// and apply the appropriate level of indentation. /// /// - Parameters: @@ -569,7 +569,7 @@ public class PrettyPrinter { /// /// - Returns: A String containing the formatted source code. public func prettyPrint() -> String { - // Keep track of the indicies of the .open and .break token locations. + // Keep track of the indices of the .open and .break token locations. var delimIndexStack = [Int]() // Keep a running total of the token lengths. var total = 0 @@ -584,7 +584,7 @@ public class PrettyPrinter { lengths.append(0) // Open tokens have lengths equal to the total of the contents of its group. The value is - // calcualted when close tokens are encountered. + // calculated when close tokens are encountered. case .open: lengths.append(-total) delimIndexStack.append(i) diff --git a/Sources/SwiftFormatPrettyPrint/Token.swift b/Sources/SwiftFormatPrettyPrint/Token.swift index 0684bb29e..431edb288 100644 --- a/Sources/SwiftFormatPrettyPrint/Token.swift +++ b/Sources/SwiftFormatPrettyPrint/Token.swift @@ -108,7 +108,7 @@ enum BreakKind: Equatable { case reset /// A `contextual` break acts as either a `continue` break or maintains the existing level of - /// indentation when it fires. The contextual breaking beahvior of a given contextual breaking + /// indentation when it fires. The contextual breaking behavior of a given contextual breaking /// scope (i.e. inside a `contextualBreakingStart`/`contextualBreakingEnd` region) is set by the /// first child `contextualBreakingStart`/`contextualBreakingEnd` pair. When the first child is /// multiline the contextual breaks maintain indentation and they are continuations otherwise. diff --git a/Sources/SwiftFormatRules/BeginDocumentationCommentWithOneLineSummary.swift b/Sources/SwiftFormatRules/BeginDocumentationCommentWithOneLineSummary.swift index 338024748..49b76b0e5 100644 --- a/Sources/SwiftFormatRules/BeginDocumentationCommentWithOneLineSummary.swift +++ b/Sources/SwiftFormatRules/BeginDocumentationCommentWithOneLineSummary.swift @@ -162,7 +162,7 @@ public final class BeginDocumentationCommentWithOneLineSummary: SyntaxLintRule { /// /// This method is a fallback for platforms (like Linux, currently) where `String` does not /// support `NSLinguisticTagger` and its related APIs. It will fail to catch certain kinds of - /// sentences (such as those containing abbrevations that are followed by a period, like "Dr.") + /// sentences (such as those containing abbreviations that are followed by a period, like "Dr.") /// that the more advanced API can handle. private func nonLinguisticSentenceApproximations(in text: String) -> ( sentences: [String], trailingText: Substring diff --git a/Sources/SwiftFormatRules/DeclSyntaxProtocol+Comments.swift b/Sources/SwiftFormatRules/DeclSyntaxProtocol+Comments.swift index e0728f333..a496c92c8 100644 --- a/Sources/SwiftFormatRules/DeclSyntaxProtocol+Comments.swift +++ b/Sources/SwiftFormatRules/DeclSyntaxProtocol+Comments.swift @@ -87,8 +87,8 @@ extension DeclSyntaxProtocol { var returnsDescription: String? var throwsDescription: String? // Takes the first sentence of the comment, and counts the number of lines it uses. - let oneSenteceSummary = docComment.components(separatedBy: ".").first - let numOfOneSentenceLines = oneSenteceSummary!.components(separatedBy: .newlines).count + let oneSentenceSummary = docComment.components(separatedBy: ".").first + let numOfOneSentenceLines = oneSentenceSummary!.components(separatedBy: .newlines).count // Iterates to all the comments after the one sentence summary to find the parameter(s) // return tags and get their description. @@ -114,7 +114,7 @@ extension DeclSyntaxProtocol { } else { switch currentSection { case .parameters: - // After the paramters tag is found the following lines should be the parameters + // After the parameters tag is found the following lines should be the parameters // description. guard let index = trimmedLine.firstIndex(of: ":") else { continue } let name = trimmedLine[.. DeclModifierSyntax { let id = TokenSyntax.identifier(name, trailingTrivia: .spaces(1)) let newModifier = DeclModifierSyntax(name: id, detail: nil) diff --git a/Sources/SwiftFormatRules/OrderedImports.swift b/Sources/SwiftFormatRules/OrderedImports.swift index fcff99231..81e0fe2e3 100644 --- a/Sources/SwiftFormatRules/OrderedImports.swift +++ b/Sources/SwiftFormatRules/OrderedImports.swift @@ -188,7 +188,7 @@ public final class OrderedImports: SyntaxFormatRule { } /// Sort the list of import lines lexicographically by the import path name. Any comments above an - /// import lines should be assocaited with it, and move with the line during sorting. We also emit + /// import lines should be associated with it, and move with the line during sorting. We also emit /// a linter error if an import line is discovered to be out of order. private func formatImports(_ imports: [Line]) -> [Line] { var linesWithLeadingComments: [(import: Line, comments: [Line])] = [] @@ -280,7 +280,7 @@ fileprivate func joinLines(_ inputLineLists: [Line]...) -> [Line] { } /// This function transforms the statements in a CodeBlockItemListSyntax object into a list of Line -/// obejcts. Blank lines and standalone comments are represented by their own Line object. Code with +/// objects. Blank lines and standalone comments are represented by their own Line object. Code with /// a trailing comment are represented together in the same Line. fileprivate func generateLines(codeBlockItemList: CodeBlockItemListSyntax, context: Context) -> [Line] diff --git a/Sources/SwiftFormatRules/UseShorthandTypeNames.swift b/Sources/SwiftFormatRules/UseShorthandTypeNames.swift index 139691ed0..1a57c415a 100644 --- a/Sources/SwiftFormatRules/UseShorthandTypeNames.swift +++ b/Sources/SwiftFormatRules/UseShorthandTypeNames.swift @@ -197,7 +197,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule { return (first, second) } - /// Retuns a `TypeSyntax` representing a shorthand array type (e.g., `[Foo]`) with the given + /// Returns a `TypeSyntax` representing a shorthand array type (e.g., `[Foo]`) with the given /// element type and trivia. private func shorthandArrayType( element: TypeSyntax, diff --git a/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift b/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift index b560edf3e..c514820d2 100644 --- a/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift +++ b/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift @@ -201,7 +201,7 @@ fileprivate enum AccessLevel { /// a struct that contains the given properties. /// /// The rules for default memberwise initializer access levels are defined in The Swift -/// Programming Languge: +/// Programming Language: /// https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html#ID21 /// /// - Parameter properties: The properties contained within the struct. diff --git a/Sources/SwiftFormatRules/ValidateDocumentationComments.swift b/Sources/SwiftFormatRules/ValidateDocumentationComments.swift index 2011e784a..c142e5d08 100644 --- a/Sources/SwiftFormatRules/ValidateDocumentationComments.swift +++ b/Sources/SwiftFormatRules/ValidateDocumentationComments.swift @@ -49,7 +49,7 @@ public final class ValidateDocumentationComments: SyntaxLintRule { guard let params = commentInfo.parameters else { return .skipChildren } // If a single sentence summary is the only documentation, parameter(s) and - // returns tags may be ommitted. + // returns tags may be omitted. if commentInfo.oneSentenceSummary != nil && commentInfo.commentParagraphs!.isEmpty && params .isEmpty && commentInfo.returnsDescription == nil { @@ -79,7 +79,7 @@ public final class ValidateDocumentationComments: SyntaxLintRule { return .skipChildren } - // Ensures that the parameters of the documantation and the function signature + // Ensures that the parameters of the documentation and the function signature // are the same. if (params.count != funcParameters.count) || !parametersAreEqual( params: params, funcParam: funcParameters) @@ -132,7 +132,7 @@ public final class ValidateDocumentationComments: SyntaxLintRule { } /// Iterates through every parameter of paramList and returns a list of the -/// paramters identifiers. +/// parameters identifiers. fileprivate func funcParametersIdentifiers(in paramList: FunctionParameterListSyntax) -> [String] { var funcParameters = [String]() for parameter in paramList { diff --git a/Tests/SwiftFormatPrettyPrintTests/ForInStmtTests.swift b/Tests/SwiftFormatPrettyPrintTests/ForInStmtTests.swift index b28c6c906..0349f0b6f 100644 --- a/Tests/SwiftFormatPrettyPrintTests/ForInStmtTests.swift +++ b/Tests/SwiftFormatPrettyPrintTests/ForInStmtTests.swift @@ -76,11 +76,11 @@ final class ForInStmtTests: PrettyPrintTestCase { func testForLoopFullWrap() { let input = """ - for item in aVeryLargeContainterObject where largeObject.hasProperty() && condition { + for item in aVeryLargeContainerObject where largeObject.hasProperty() && condition { let a = 123 let b = 456 } - for item in aVeryLargeContainterObject where tinyObj.hasProperty() && condition { + for item in aVeryLargeContainerObject where tinyObj.hasProperty() && condition { let a = 123 let b = 456 } @@ -89,7 +89,7 @@ final class ForInStmtTests: PrettyPrintTestCase { let expected = """ for item - in aVeryLargeContainterObject + in aVeryLargeContainerObject where largeObject.hasProperty() && condition @@ -98,7 +98,7 @@ final class ForInStmtTests: PrettyPrintTestCase { let b = 456 } for item - in aVeryLargeContainterObject + in aVeryLargeContainerObject where tinyObj.hasProperty() && condition { diff --git a/Tests/SwiftFormatRulesTests/BeginDocumentationCommentWithOneLineSummaryTests.swift b/Tests/SwiftFormatRulesTests/BeginDocumentationCommentWithOneLineSummaryTests.swift index 998279f77..9187eb947 100644 --- a/Tests/SwiftFormatRulesTests/BeginDocumentationCommentWithOneLineSummaryTests.swift +++ b/Tests/SwiftFormatRulesTests/BeginDocumentationCommentWithOneLineSummaryTests.swift @@ -13,7 +13,7 @@ final class BeginDocumentationCommentWithOneLineSummaryTests: LintOrFormatRuleTe /// Returns a bottle of Dr Pepper from the vending machine. public func drPepper(from vendingMachine: VendingMachine) -> Soda {} - /// Contains a comment as description that needs a sentece + /// Contains a comment as description that needs a sentence /// of two lines of code. public var twoLinesForOneSentence = "test" @@ -46,7 +46,7 @@ final class BeginDocumentationCommentWithOneLineSummaryTests: LintOrFormatRuleTe XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence( "Returns a bottle of Dr Pepper from the vending machine.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence( - "Contains a comment as description that needs a sentece of two lines of code.")) + "Contains a comment as description that needs a sentence of two lines of code.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence("The background color of the view.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence("Returns the sum of the numbers.")) } @@ -107,7 +107,7 @@ final class BeginDocumentationCommentWithOneLineSummaryTests: LintOrFormatRuleTe /// Returns a bottle of Dr Pepper from the vending machine. public func drPepper(from vendingMachine: VendingMachine) -> Soda {} - /// Contains a comment as description that needs a sentece + /// Contains a comment as description that needs a sentence /// of two lines of code. public var twoLinesForOneSentence = "test" @@ -140,7 +140,7 @@ final class BeginDocumentationCommentWithOneLineSummaryTests: LintOrFormatRuleTe XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence( "Returns a bottle of Dr Pepper from the vending machine.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence( - "Contains a comment as description that needs a sentece of two lines of code.")) + "Contains a comment as description that needs a sentence of two lines of code.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence("The background color of the view.")) XCTAssertNotDiagnosed(.addBlankLineAfterFirstSentence("Returns the sum of the numbers.")) #endif diff --git a/Tests/SwiftFormatRulesTests/UseEarlyExitsTests.swift b/Tests/SwiftFormatRulesTests/UseEarlyExitsTests.swift index 7aee33664..9f7f443ae 100644 --- a/Tests/SwiftFormatRulesTests/UseEarlyExitsTests.swift +++ b/Tests/SwiftFormatRulesTests/UseEarlyExitsTests.swift @@ -89,7 +89,7 @@ final class UseEarlyExitsTests: LintOrFormatRuleTestCase { // Comment 4 var result = 0 for value in values { - result += invertedCombobulatoryFactor(of: value) + result += invertedCombobulatorFactor(of: value) } return result } else { @@ -121,7 +121,7 @@ final class UseEarlyExitsTests: LintOrFormatRuleTestCase { // Comment 4 var result = 0 for value in values { - result += invertedCombobulatoryFactor(of: value) + result += invertedCombobulatorFactor(of: value) } return result } diff --git a/Tests/SwiftFormatRulesTests/UseShorthandTypeNamesTests.swift b/Tests/SwiftFormatRulesTests/UseShorthandTypeNamesTests.swift index 9c05db317..bdcd4ac5a 100644 --- a/Tests/SwiftFormatRulesTests/UseShorthandTypeNamesTests.swift +++ b/Tests/SwiftFormatRulesTests/UseShorthandTypeNamesTests.swift @@ -397,7 +397,7 @@ final class UseShorthandTypeNamesTests: LintOrFormatRuleTestCase { """) } - func testOptionalsNestedInOtherTypseInStoredVarsAreStillChanged() { + func testOptionalsNestedInOtherTypesInStoredVarsAreStillChanged() { XCTAssertFormatting( UseShorthandTypeNames.self, input: diff --git a/Tests/SwiftFormatRulesTests/ValidateDocumentationCommentsTests.swift b/Tests/SwiftFormatRulesTests/ValidateDocumentationCommentsTests.swift index 48990935f..4aafb32e2 100644 --- a/Tests/SwiftFormatRulesTests/ValidateDocumentationCommentsTests.swift +++ b/Tests/SwiftFormatRulesTests/ValidateDocumentationCommentsTests.swift @@ -177,7 +177,7 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase { /// Parameter(s) and Returns tags may be omitted only if the single-sentence /// brief summary fully describes the meaning of those items and including the /// tags would only repeat what has already been said - func ommitedFunc(p1: Int) + func omittedFunc(p1: Int) """ performLint(ValidateDocumentationComments.self, input: input) XCTAssertNotDiagnosed(.useSingularParameter) @@ -196,9 +196,9 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase { XCTAssertNotDiagnosed(.documentErrorsThrown(funcName: "pluralParam")) XCTAssertNotDiagnosed(.removeThrowsComment(funcName: "pluralParam")) - XCTAssertNotDiagnosed(.documentReturnValue(funcName: "ommitedFunc")) - XCTAssertNotDiagnosed(.removeReturnComment(funcName: "ommitedFunc")) - XCTAssertNotDiagnosed(.parametersDontMatch(funcName: "ommitedFunc")) + XCTAssertNotDiagnosed(.documentReturnValue(funcName: "omittedFunc")) + XCTAssertNotDiagnosed(.removeReturnComment(funcName: "omittedFunc")) + XCTAssertNotDiagnosed(.parametersDontMatch(funcName: "omittedFunc")) } func testSeparateLabelAndIdentifier() { diff --git a/build-script-helper.py b/build-script-helper.py index ca03327fa..5b3f83516 100755 --- a/build-script-helper.py +++ b/build-script-helper.py @@ -133,7 +133,7 @@ def run(args): verbose=args.verbose ) cmd = [args.swift_exec, 'build', '--show-bin-path'] + swiftpm_args - bin_path = check_output(cmd, env=env, caputre_stderr=False, verbose=args.verbose).strip() + bin_path = check_output(cmd, env=env, capture_stderr=False, verbose=args.verbose).strip() for prefix in args.install_prefixes: cmd = ['rsync', '-a', os.path.join(bin_path, 'swift-format'), os.path.join(prefix, 'bin')] @@ -206,10 +206,10 @@ def check_call(cmd, verbose, env=os.environ, **kwargs): print(' '.join([escape_cmd_arg(arg) for arg in cmd])) return subprocess.check_call(cmd, env=env, stderr=subprocess.STDOUT, **kwargs) -def check_output(cmd, verbose, env=os.environ, caputre_stderr=True, **kwargs): +def check_output(cmd, verbose, env=os.environ, capture_stderr=True, **kwargs): if verbose: print(' '.join([escape_cmd_arg(arg) for arg in cmd])) - if caputre_stderr: + if capture_stderr: stderr = subprocess.STDOUT else: stderr = subprocess.DEVNULL