Skip to content

Commit 6625710

Browse files
committed
Fixup several warnings
- Remove unnecessary `try` statements for function calls that do not throw - Remove unnecessary `#expect` checks for values that cannot be `nil`
1 parent a4b2da7 commit 6625710

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

Sources/Commands/Utilities/PluginDelegate.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ final class PluginDelegate: PluginInvocationDelegate {
423423
func lookupDescription(
424424
for moduleName: String,
425425
destination: BuildParameters.Destination
426-
) throws -> ModuleBuildDescription? {
427-
try buildPlan.buildModules.first {
426+
) -> ModuleBuildDescription? {
427+
buildPlan.buildModules.first {
428428
$0.module.name == moduleName && $0.buildParameters.destination == destination
429429
}
430430
}
@@ -434,9 +434,9 @@ final class PluginDelegate: PluginInvocationDelegate {
434434
// historically how this was setup. Ideally we should be building for both "host"
435435
// and "target" if module is configured for them but that would require changing
436436
// `PluginInvocationSymbolGraphResult` to carry multiple directories.
437-
let description = if let targetDescription = try lookupDescription(for: targetName, destination: .target) {
437+
let description = if let targetDescription = lookupDescription(for: targetName, destination: .target) {
438438
targetDescription
439-
} else if let hostDescription = try lookupDescription(for: targetName, destination: .host) {
439+
} else if let hostDescription = lookupDescription(for: targetName, destination: .host) {
440440
hostDescription
441441
} else {
442442
throw InternalError("could not find a target named: \(targetName)")

Tests/FunctionalTests/PluginTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ final class PluginTests {
778778
) async throws {
779779
// Find the named plugin.
780780
let plugins = package.modules.compactMap{ $0.underlying as? PluginModule }
781-
let plugin = try #require(plugins.first(where: { $0.name == pluginName }), "There is no plugin target named ‘\(pluginName)")
782-
try #require(plugin.type == .plugin, "Target \(plugin) isn’t a plugin")
781+
let plugin = #require(plugins.first(where: { $0.name == pluginName }), "There is no plugin target named ‘\(pluginName)")
782+
#require(plugin.type == .plugin, "Target \(plugin) isn’t a plugin")
783783

784784
// Find the named input targets to the plugin.
785785
var modules: [ResolvedModule] = []

Tests/FunctionalTests/StaticBinaryLibrary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct StaticBinaryLibraryTests {
2424

2525
try await withKnownIssue {
2626
try await fixture(name: "BinaryLibraries") { fixturePath in
27-
let (stdout, stderr) = try await executeSwiftRun(
27+
let (stdout, _) = try await executeSwiftRun(
2828
fixturePath.appending("Static").appending("Package1"),
2929
"Example",
3030
extraArgs: ["--experimental-prune-unused-dependencies"],

Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import struct SPMBuildCore.BuildSystemProvider
2020
private struct SwiftPMTests {
2121
@Test(.requireHostOS(.macOS))
2222
func binaryTargets() async throws {
23-
try await withKnownIssue("error: the path does not point to a valid framework:") {
23+
await withKnownIssue("error: the path does not point to a valid framework:") {
2424
try await binaryTargetsFixture { fixturePath in
2525
do {
2626
await withKnownIssue("error: local binary target ... does not contain a binary artifact") {

Tests/PackageGraphTests/ModulesGraphTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,7 @@ struct ModulesGraphTests {
22832283
let observability = try loadUnsafeModulesGraph(toolsVersion: .v6_1)
22842284

22852285
#expect(observability.diagnostics.count == 3)
2286-
try testDiagnostics(observability.diagnostics) { result in
2286+
testDiagnostics(observability.diagnostics) { result in
22872287
var expectedMetadata = ObservabilityMetadata()
22882288
expectedMetadata.moduleName = "Foo2"
22892289
let diagnostic1 = try #require(result.checkUnordered(

Tests/PackageSigningTests/SigningTests.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,8 @@ struct SigningTests {
786786
return
787787
}
788788
switch signingEntity {
789-
case .recognized(_, let name, let organizationalUnit, let organization):
790-
#expect(name != nil)
791-
#expect(organizationalUnit != nil)
792-
#expect(organization != nil)
789+
case .recognized:
790+
break
793791
case .unrecognized(let name, let organizationalUnit, let organization):
794792
#expect(name != nil)
795793
#expect(organizationalUnit != nil)
@@ -841,10 +839,8 @@ struct SigningTests {
841839
return
842840
}
843841
switch signingEntity {
844-
case .recognized(_, let name, let organizationalUnit, let organization):
845-
#expect(name != nil)
846-
#expect(organizationalUnit != nil)
847-
#expect(organization != nil)
842+
case .recognized:
843+
break
848844
case .unrecognized(let name, let organizationalUnit, let organization):
849845
#expect(name != nil)
850846
#expect(organizationalUnit != nil)
@@ -896,10 +892,8 @@ struct SigningTests {
896892
return
897893
}
898894
switch signingEntity {
899-
case .recognized(_, let name, let organizationalUnit, let organization):
900-
#expect(name != nil)
901-
#expect(organizationalUnit != nil)
902-
#expect(organization != nil)
895+
case .recognized:
896+
break
903897
case .unrecognized(let name, let organizationalUnit, let organization):
904898
#expect(name != nil)
905899
#expect(organizationalUnit != nil)

Tests/WorkspaceTests/ToolsVersionSpecificationRewriterTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fileprivate struct ToolsVersionSpecificationRewriterTests {
120120
)
121121

122122
// resultHandler(try inMemoryFileSystem.readFileContents(manifestFilePath))
123-
let actual = try #require(try inMemoryFileSystem.readFileContents(manifestFilePath))
123+
let actual = try inMemoryFileSystem.readFileContents(manifestFilePath)
124124
#expect(actual.validDescription == expected, "Actual is not expected")
125125
}
126126

0 commit comments

Comments
 (0)