Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Keep the scripts within 120 columns too

Țugui Dragoș82dfeebe81b4
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e0993035..0bb85df2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -237,7 +237,8 @@ read in one sitting.
Apple's documentation). No history and no lab notes: a fixed bug belongs in the commit message, and the comment
keeps only the rule it left. Don't narrate what the next line does.
- **Lines within 120 columns**, code and comments alike. A string is never split to make its line fit, so a
- sentence can still be found with a search: `LineLengthTests` measures each line without its strings.
+ sentence can still be found with a search: `LineLengthTests` measures each line of Swift without its strings,
+ and a script's line as it is written.
- **No dead code.** Whatever your change leaves unused (a function, a type, a string, a file, a test helper)
goes in the same change.
- **One English: American**, as the Apple Style Guide writes it: color, catalog, license, canceled, and the
diff --git a/Logo/export.sh b/Logo/export.sh
index 960f6b6a..551b6a3d 100755
--- a/Logo/export.sh
+++ b/Logo/export.sh
@@ -4,5 +4,7 @@
set -euo pipefail
cd "${0:A:h}"
ictool="$(xcode-select -p)/../Applications/Icon Composer.app/Contents/Executables/ictool"
-"$ictool" Peel.icon --export-image --output-file Peel.png --platform macOS --rendition Default --width 320 --height 320 --scale 1
-"$ictool" Peel.icon --export-image --output-file Peel-Dark.png --platform macOS --rendition Dark --width 1024 --height 1024 --scale 1
+"$ictool" Peel.icon --export-image --output-file Peel.png \
+ --platform macOS --rendition Default --width 320 --height 320 --scale 1
+"$ictool" Peel.icon --export-image --output-file Peel-Dark.png \
+ --platform macOS --rendition Dark --width 1024 --height 1024 --scale 1
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LineLengthTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LineLengthTests.swift
index a526fd1d..b3f72f68 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LineLengthTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LineLengthTests.swift
@@ -22,6 +22,23 @@ struct LineLengthTests {
#expect(long.isEmpty, "\(long.count) lines:\n\(long.prefix(40).joined(separator: "\n"))")
}
+ /// A script's line is measured as it is written: its quotes follow its own language's rules.
+ @Test func everyScriptLineFitsIn120Columns() throws {
+ var long: [String] = []
+ for folder in ["Scripts", "Logo", ".github/workflows"] {
+ let root = Self.repository.appending(path: folder, directoryHint: .isDirectory)
+ for file in try FileManager.default.contentsOfDirectory(at: root, includingPropertiesForKeys: nil)
+ where ["sh", "py", "yml"].contains(file.pathExtension) {
+ let lines = try String(contentsOf: file, encoding: .utf8)
+ .split(separator: "\n", omittingEmptySubsequences: false)
+ for (index, line) in lines.enumerated() where line.count > 120 {
+ long.append("\(folder)/\(file.lastPathComponent):\(index + 1) is \(line.count) columns")
+ }
+ }
+ }
+ #expect(long.isEmpty, "\(long.joined(separator: "\n"))")
+ }
+
@Test func aStringLiteralDoesNotCount() {
let literal = String(repeating: "word ", count: 40)
let interpolated = " let text = \"\(literal)\\(value(\"\(literal)\"))\(literal)\""