| name | fix-lint |
| description | Fix SwiftLint errors and SwiftFormat violations in NetMonitor-2.0. Use when the pre-commit hook blocks a commit, the CI lint job fails, or before opening a PR. Errors block commits; warnings do not. |
Fix Lint — NetMonitor-2.0
Quick check — what's failing?
swiftlint lint --quiet
swiftlint lint --quiet --reporter xcode
swiftformat --lint .
Auto-fix everything auto-fixable
swiftlint --fix --quiet
swiftformat .
Always re-run after auto-fixing to confirm no errors remain:
swiftlint lint --quiet | grep ": error:" | wc -l
swiftformat --lint .
Common errors and how to fix them
todo_needs_ticket — TODO without beads ID
File the beads issue first (bd create), then reference it.
force_unwrapping — force unwrap (!)
let value = someOptional!
guard let value = someOptional else { return }
let value = someOptional ?? defaultValue
cyclomatic_complexity — function too complex
Break the function into smaller private helper functions. Threshold: warning at 12, error at 20.
type_body_length — struct/class too large
Extract logical groupings into extensions or separate types.
identifier_name — variable name too short
let n = items.count
let itemCount = items.count
Allowed single-char names: i, j, k, x, y, z, id, ip.
line_length — line too long
Break long lines. Warning at 150 chars, error at 250. Comments and URLs are exempt.
Lint-related files
| File | Purpose |
|---|
.swiftlint.yml | All SwiftLint rules and thresholds |
.swiftformat | SwiftFormat rules (correctness-only baseline) |
.githooks/pre-commit | Runs both tools on staged files before each commit |
.github/workflows/lint.yml | CI jobs: swiftlint + swiftformat + bare-TODO check |
Suppress a specific violation (use sparingly)
let image = UIImage(named: "logo")!
...
Always add a comment explaining why suppression is justified.