Skip to content

Commit 7f92276

Browse files
authored
plugin, containertool: Remove unnecessarily broad Foundation imports (#59)
Motivation ---------- In many places we import a whole module but only use one or two structs or classes. In these cases, importing just the parts we need makes dependencies clearer. Modifications ------------- * Where only one definition is used, constrain the import statement to only that definition. * Remove a couple of Foundation imports which were completely unused. Result ------ No functional change. Dependencies are clearer. Test Plan --------- Tests continue to pass.
1 parent 2583f04 commit 7f92276

File tree

8 files changed

+7
-9
lines changed

8 files changed

+7
-9
lines changed

Plugins/ContainerImageBuilder/Pipe+lines.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
15+
import class Foundation.Pipe
1616

1717
extension Pipe {
1818
var lines: AsyncThrowingStream<String, Error> {

Sources/ContainerRegistry/Blobs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616
import HTTPTypes
17-
import Crypto
17+
import struct Crypto.SHA256
1818

1919
/// Calculates the digest of a blob of data.
2020
/// - Parameter data: Blob of data to digest.

Sources/ContainerRegistry/ImageManifest+Digest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Foundation
16-
import Crypto
16+
import struct Crypto.SHA256
1717

1818
public extension ImageManifest {
1919
var digest: String {

Sources/Tar/tar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
15+
import struct Foundation.Data
1616

1717
// This file defines a basic tar writer which produces POSIX tar files.
1818
// This avoids the need to depend on a system-provided tar binary.

Sources/containertool/Extensions/RegistryClient+Layers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
15+
import struct Foundation.Data
1616
import ContainerRegistry
1717

1818
extension RegistryClient {

Tests/ContainerRegistryTests/SmokeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
15+
import class Foundation.ProcessInfo
1616
import ContainerRegistry
1717
import Testing
1818

Tests/TarTests/TarUnitTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import Testing
1716

1817
@testable import Tar

Tests/containertoolTests/ZlibTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
@testable import containertool
16-
import Crypto
17-
import Foundation
16+
import struct Crypto.SHA256
1817
import Testing
1918

2019
// Check that compressing the same data on macOS and Linux produces the same output.

0 commit comments

Comments
 (0)