Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spelling #450

Merged
merged 21 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Plugins/LintPlugin/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftFormatPrettyPrint/PrettyPrint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormatPrettyPrint/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftFormatRules/DeclSyntaxProtocol+Comments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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[..<index].trimmingCharacters(in: .init(charactersIn: " -:"))
Expand All @@ -138,7 +138,7 @@ extension DeclSyntaxProtocol {
}

return ParseComment(
oneSentenceSummary: oneSenteceSummary,
oneSentenceSummary: oneSentenceSummary,
commentParagraphs: commentParagraphs,
parameters: params,
throwsDescription: throwsDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension ModifierListSyntax {
return self
}

/// Returns a foramatted declaration modifier token with the given name.
/// Returns a formatted declaration modifier token with the given name.
func createModifierToken(name: String) -> DeclModifierSyntax {
let id = TokenSyntax.identifier(name, trailingTrivia: .spaces(1))
let newModifier = DeclModifierSyntax(name: id, detail: nil)
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftFormatRules/OrderedImports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])] = []
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormatRules/UseShorthandTypeNames.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormatRules/UseSynthesizedInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftFormatPrettyPrintTests/ForInStmtTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -89,7 +89,7 @@ final class ForInStmtTests: PrettyPrintTestCase {
let expected =
"""
for item
in aVeryLargeContainterObject
in aVeryLargeContainerObject
where
largeObject.hasProperty()
&& condition
Expand All @@ -98,7 +98,7 @@ final class ForInStmtTests: PrettyPrintTestCase {
let b = 456
}
for item
in aVeryLargeContainterObject
in aVeryLargeContainerObject
where tinyObj.hasProperty()
&& condition
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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."))
}
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftFormatRulesTests/UseEarlyExitsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this doesn't matter. It's a playful guess. Happy to drop

}
return result
} else {
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ final class UseShorthandTypeNamesTests: LintOrFormatRuleTestCase {
""")
}

func testOptionalsNestedInOtherTypseInStoredVarsAreStillChanged() {
func testOptionalsNestedInOtherTypesInStoredVarsAreStillChanged() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Typse
+Types

XCTAssertFormatting(
UseShorthandTypeNames.self,
input:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down Expand Up @@ -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
Expand Down