Skip to content

Commit a542d27

Browse files
dadachiclaude
andcommitted
Remove unused String helpers: image(withAttributes:size:), isAlphanumeric
The String.image(...) renderer and both isAlphanumeric() overloads have no production callers — only their own tests reference them. Drop the helpers and their tests; UIKit/Foundation imports collapse to Foundation since the remaining isBlank / isValidEmail need only that. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c2bbf36 commit a542d27

2 files changed

Lines changed: 1 addition & 60 deletions

File tree

NativeAppTemplate/Extensions/String+Extensions.swift

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,9 @@
33
// NativeAppTemplate
44
//
55

6-
import UIKit
6+
import Foundation
77

88
extension String {
9-
/// Generates a `UIImage` instance from this string using a specified
10-
/// attributes and size.
11-
///
12-
/// - Parameters:
13-
/// - attributes: to draw this string with. Default is `nil`.
14-
/// - size: of the image to return.
15-
/// - Returns: a `UIImage` instance from this string using a specified
16-
/// attributes and size, or `nil` if the operation fails.
17-
func image(withAttributes attributes: [NSAttributedString.Key: Any]? = nil, size: CGSize? = nil) -> UIImage? {
18-
let size = size ?? (self as NSString).size(withAttributes: attributes)
19-
return UIGraphicsImageRenderer(size: size).image { _ in
20-
(self as NSString).draw(
21-
in: CGRect(origin: .zero, size: size),
22-
withAttributes: attributes
23-
)
24-
}
25-
}
26-
27-
func isAlphanumeric() -> Bool {
28-
rangeOfCharacter(from: CharacterSet.alphanumerics.inverted) == nil && !isEmpty
29-
}
30-
31-
func isAlphanumeric(ignoreDiacritics: Bool = false) -> Bool {
32-
if ignoreDiacritics {
33-
range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil && !isEmpty
34-
} else {
35-
isAlphanumeric()
36-
}
37-
}
38-
399
var isBlank: Bool {
4010
trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
4111
}

NativeAppTemplateTests/Extensions/StringExtensionsTest.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,10 @@
33
// NativeAppTemplate
44
//
55

6-
import CoreGraphics
76
@testable import NativeAppTemplate
87
import Testing
98

109
struct StringExtensionsTest {
11-
@Test(arguments: [
12-
("hello123", true),
13-
("ABC", true),
14-
("abc", true),
15-
("123", true),
16-
("Hello World", false),
17-
("hello!", false),
18-
("hello@world", false),
19-
("", false)
20-
])
21-
func isAlphanumeric(input: String, expected: Bool) {
22-
#expect(input.isAlphanumeric() == expected)
23-
}
24-
25-
@Test
26-
func isAlphanumericIgnoringDiacritics() {
27-
#expect("hello123".isAlphanumeric(ignoreDiacritics: true) == true)
28-
#expect("ABC123".isAlphanumeric(ignoreDiacritics: true) == true)
29-
#expect("hello world".isAlphanumeric(ignoreDiacritics: true) == false)
30-
#expect("".isAlphanumeric(ignoreDiacritics: true) == false)
31-
}
32-
33-
@Test
34-
func imageGeneration() {
35-
let image = "A".image(size: CGSize(width: 50, height: 50))
36-
#expect(image != nil)
37-
}
38-
3910
@Test(arguments: [
4011
("", true),
4112
(" ", true),

0 commit comments

Comments
 (0)