Skip to content

Commit 57a2f2c

Browse files
refactor: codebase cleanup for open source readiness (#35)
* refactor(models): split Models.swift into separate files - Extract PortInfo.swift with port/process data model - Extract ProcessType.swift with process categorization enum - Extract WatchedPort.swift with notification preferences - Extract ProcessGroup.swift for tree view grouping - Add Errors.swift with PortKillerError enum - Add comprehensive JSDoc documentation to all models Each model file is now under 100 lines for better maintainability. * feat(services): add centralized service layer - Add NotificationService for system notification management - Add PermissionService for accessibility/notification permissions - Add PortGroupingService (actor) for centralized grouping logic - Extract duplicated grouping code from views into shared service - All services use @mainactor or actor for thread safety * refactor(views): split MenuBarView into focused components - MenuBarView.swift (120 lines) - Main container - MenuBarHeader.swift - Search bar and header - MenuBarPortList.swift - Port list rendering - MenuBarPortRow.swift - Individual port row - MenuBarTreeView.swift - Tree view mode - MenuBarActions.swift - Kill all, settings, quit actions Split 580-line file into 6 focused files under 150 lines each. * refactor(views): split SettingsView into reusable sections - SettingsView.swift - Main settings container - SettingsComponents.swift - Reusable row/group components - PermissionsSection.swift - Accessibility and notification settings - GeneralSettingsSection.swift - Launch at login and general prefs Split 526-line file into 4 focused files with reusable components. * refactor(views): split PortTableView into focused components - PortTableView.swift - Main table container with toolbar - PortListRow.swift - Individual port row with actions - PortSortOptions.swift - Sort enum and comparison logic Split 444-line file into 3 focused files. * refactor(components): split ProcessGroupListRow into focused components - ProcessGroupRow.swift - Process group header with expand/collapse - NestedPortRow.swift - Individual nested port row with actions Split 270-line file into 2 focused files. * refactor(core): modernize core components - AppState: Add JSDoc documentation, improve organization - UpdateManager: Already uses @observable macro - PortScanner: Add comprehensive documentation - Constants: Add UIConstants and AppConstants enums Standardize patterns across core components. * test: add Swift Testing framework with initial tests - Add PortKillerTests target to Package.swift - Add ProcessTypeTests for process categorization - Add PortFilterTests for filter matching logic Uses Swift Testing framework (not XCTest) for modern test syntax. * docs: add contribution guidelines and style guide - CONTRIBUTING.md: Development setup, PR process, issue reporting - STYLE_GUIDE.md: Swift naming conventions, SwiftUI patterns, file organization, documentation format Prepares project for open source contributions. * ci: add PR validation workflow - Build & Test job: Debug/Release builds, parallel tests - Lint job: TODO/FIXME check, file line count, doc headers - Validate Package job: Package.swift validation Runs on push to main and all pull requests. * fix(test): correct filter test to not match command field * fix(settings): add keyboard shortcuts configuration (closes #32) - Add ShortcutsSection.swift with KeyboardShortcuts.Recorder - Users can now customize the toggle main window shortcut - Includes reset to default button (⌘⇧P) - Shows accessibility permission warning when needed Fixes issue where Cmd+Shift+P conflicts with VSCode Command Palette. * fix(ui): improve panel resizing with proper column width constraints (closes #33) - Add navigationSplitViewColumnWidth modifiers to all three columns - Sidebar: min 180, ideal 220, max 280 - Content: min 300, ideal 400, max infinity - Detail: min 280, ideal 320, max 400 - Remove redundant .frame(minWidth:) from SidebarView and PortDetailView Fixes erratic resizing behavior reported in issue #33. * fix: correct Twitter handle to @productdevbook * refactor(menu): move Open PortKiller above Sponsors * refactor(menu): group action items together
1 parent 7758648 commit 57a2f2c

40 files changed

+4816
-1931
lines changed

.github/workflows/ci.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: Build & Test
16+
runs-on: macos-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Xcode
23+
uses: maxim-lobanov/setup-xcode@v1
24+
with:
25+
xcode-version: latest-stable
26+
27+
- name: Cache Swift Package Manager
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
.build
32+
~/Library/Caches/org.swift.swiftpm
33+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
34+
restore-keys: |
35+
${{ runner.os }}-spm-
36+
37+
- name: Resolve dependencies
38+
run: swift package resolve
39+
40+
- name: Build (Debug)
41+
run: swift build
42+
43+
- name: Build (Release)
44+
run: swift build -c release
45+
46+
- name: Run Tests
47+
run: swift test --parallel
48+
49+
lint:
50+
name: Lint
51+
runs-on: macos-latest
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Check for TODO/FIXME comments
58+
run: |
59+
echo "Checking for TODO/FIXME comments..."
60+
TODOS=$(grep -rn "TODO\|FIXME" Sources/ --include="*.swift" || true)
61+
if [ -n "$TODOS" ]; then
62+
echo "Found TODO/FIXME comments:"
63+
echo "$TODOS"
64+
echo ""
65+
echo "Note: Please address these before merging."
66+
else
67+
echo "No TODO/FIXME comments found."
68+
fi
69+
70+
- name: Check file line counts
71+
run: |
72+
echo "Checking for files over 300 lines..."
73+
LARGE_FILES=""
74+
for file in $(find Sources -name "*.swift"); do
75+
LINES=$(wc -l < "$file")
76+
if [ "$LINES" -gt 300 ]; then
77+
LARGE_FILES="$LARGE_FILES\n$file: $LINES lines"
78+
fi
79+
done
80+
81+
if [ -n "$LARGE_FILES" ]; then
82+
echo "Warning: The following files exceed 300 lines:"
83+
echo -e "$LARGE_FILES"
84+
echo ""
85+
echo "Consider splitting these files for better maintainability."
86+
else
87+
echo "All files are within acceptable line limits."
88+
fi
89+
90+
- name: Verify documentation exists
91+
run: |
92+
echo "Checking for missing file documentation..."
93+
MISSING_DOCS=""
94+
for file in $(find Sources -name "*.swift"); do
95+
# Check if file starts with a doc comment (/** or ///)
96+
FIRST_LINES=$(head -20 "$file")
97+
if ! echo "$FIRST_LINES" | grep -q "^///\|^/\*\*\|^\s*\*"; then
98+
MISSING_DOCS="$MISSING_DOCS\n$file"
99+
fi
100+
done
101+
102+
if [ -n "$MISSING_DOCS" ]; then
103+
echo "Warning: The following files may be missing documentation headers:"
104+
echo -e "$MISSING_DOCS"
105+
else
106+
echo "All files appear to have documentation headers."
107+
fi
108+
109+
validate-package:
110+
name: Validate Package
111+
runs-on: macos-latest
112+
113+
steps:
114+
- name: Checkout code
115+
uses: actions/checkout@v4
116+
117+
- name: Setup Xcode
118+
uses: maxim-lobanov/setup-xcode@v1
119+
with:
120+
xcode-version: latest-stable
121+
122+
- name: Validate Package.swift
123+
run: |
124+
echo "Validating Package.swift..."
125+
swift package describe
126+
echo ""
127+
echo "Package structure is valid."
128+
129+
- name: Check dependencies
130+
run: |
131+
echo "Checking dependencies..."
132+
swift package show-dependencies

0 commit comments

Comments
 (0)