Add a tool (based on Periphery) that reports any unused strings.
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
project: ElementX.xcodeproj
|
project: ElementX.xcodeproj
|
||||||
schemes:
|
schemes:
|
||||||
- ElementX
|
- ElementX
|
||||||
- IntegrationTests
|
|
||||||
- UITests
|
|
||||||
- UnitTests
|
- UnitTests
|
||||||
- PreviewTests
|
- PreviewTests
|
||||||
|
- UITests
|
||||||
|
- IntegrationTests
|
||||||
targets:
|
targets:
|
||||||
- ElementX
|
- ElementX
|
||||||
- IntegrationTests
|
|
||||||
- NSE
|
- NSE
|
||||||
|
- ShareExtension
|
||||||
|
- UnitTests
|
||||||
- PreviewTests
|
- PreviewTests
|
||||||
- UITests
|
- UITests
|
||||||
- UnitTests
|
- IntegrationTests
|
||||||
report_exclude:
|
report_exclude:
|
||||||
- ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
|
- ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
|
||||||
- ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
|
- ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
|
||||||
verbose: true
|
|
||||||
retain_swift_ui_previews: true
|
retain_swift_ui_previews: true
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ struct Tools: AsyncParsableCommand {
|
|||||||
Locheck.self,
|
Locheck.self,
|
||||||
GenerateSDKMocks.self,
|
GenerateSDKMocks.self,
|
||||||
GenerateSAS.self,
|
GenerateSAS.self,
|
||||||
AppIconBanner.self])
|
AppIconBanner.self,
|
||||||
|
UnusedStrings.self])
|
||||||
}
|
}
|
||||||
|
|||||||
34
Tools/Sources/UnusedStrings.swift
Normal file
34
Tools/Sources/UnusedStrings.swift
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import ArgumentParser
|
||||||
|
import CommandLineTools
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct UnusedStrings: ParsableCommand {
|
||||||
|
static var configuration = CommandConfiguration(abstract: "Generates a report showing which strings aren't used in the project.")
|
||||||
|
|
||||||
|
@Flag(help: "Save the results to disk instead of printing them.")
|
||||||
|
var saveToFile = false
|
||||||
|
|
||||||
|
func run() throws {
|
||||||
|
try peripheryScan()
|
||||||
|
}
|
||||||
|
|
||||||
|
func peripheryScan() throws {
|
||||||
|
print("Analysing project, this may take a while…")
|
||||||
|
|
||||||
|
// Uses the existing .periphery.yml with small tweaks to the output.
|
||||||
|
let command = "periphery scan --quiet --relative-results --report-include ElementX/Sources/Generated/Strings.swift"
|
||||||
|
let output = try Zsh.run(command: command)
|
||||||
|
|
||||||
|
guard let output else {
|
||||||
|
print("Nothing reported.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if saveToFile {
|
||||||
|
try output.write(to: .projectDirectory.appending(component: "Unused Strings.txt"), atomically: true, encoding: .utf8)
|
||||||
|
print("Report saved: Unused Strings.txt")
|
||||||
|
} else {
|
||||||
|
print(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user