Files
CxIDE/scripts/lint.sh
T
cx-git-agent c118996746 feat: CxIDE v1 — native macOS SwiftUI IDE with agentic AI assistant
- SwiftUI macOS app with C++17 code analysis engine (ObjC++ bridge)
- Agentic AI loop: LLM plans → tool calls → execution → feedback loop
- 15 agent tools: file ops, terminal, git, xcode build, code intel
- 7 persistent terminal tools with background session management
- Chat sidebar with agent step rendering and auto-apply
- NVIDIA NIM API integration (Llama 3.3 70B default)
- OpenAI tool_calls format with prompt-based fallback
- Code editor with syntax highlighting and multi-tab support
- File tree, console view, terminal view
- Git integration and workspace management
2026-04-21 16:05:52 -05:00

107 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# ──────────────────────────────────────────────────────────────────
# CxIDE — Lint & Format Check
# Static analysis for Swift sources and C++ engine code.
# ──────────────────────────────────────────────────────────────────
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; YELLOW='\033[0;33m'; RESET='\033[0m'
info() { printf "${CYAN}${RESET} %s\n" "$*"; }
ok() { printf "${GREEN}${RESET} %s\n" "$*"; }
warn() { printf "${YELLOW}${RESET} %s\n" "$*"; }
ISSUES=0
# ─── Check for common Swift issues ──────────────────────────────
info "Scanning Swift sources..."
while IFS= read -r -d '' f; do
REL="${f#$ROOT_DIR/}"
# Force unwraps
COUNT=$(grep -cE '\w+!' "$f" 2>/dev/null || true)
if [[ "$COUNT" -gt 5 ]]; then
warn "$REL: $COUNT potential force unwraps"
((ISSUES++))
fi
# Force try
if grep -qE 'try!' "$f" 2>/dev/null; then
warn "$REL: contains try!"
((ISSUES++))
fi
# Print statements (in non-test, non-main files)
if [[ "$REL" != *"Test"* && "$REL" != *"main.swift" ]]; then
PRINTS=$(grep -cE '^\s*print\(' "$f" 2>/dev/null || true)
if [[ "$PRINTS" -gt 10 ]]; then
warn "$REL: $PRINTS print() calls — consider os_log or Logger"
((ISSUES++))
fi
fi
# Long lines (>150 chars)
LONG=$(awk 'length > 150' "$f" | wc -l | tr -d ' ')
if [[ "$LONG" -gt 0 ]]; then
warn "$REL: $LONG lines exceed 150 characters"
((ISSUES++))
fi
done < <(find "$ROOT_DIR" -name "*.swift" \
-not -path "*/CxSwiftAgent/*" \
-not -path "*/.build/*" \
-not -path "*/DerivedData/*" \
-print0)
# ─── Check C++ sources ──────────────────────────────────────────
info "Scanning C++ sources..."
for ext in cpp hpp mm h; do
while IFS= read -r -d '' f; do
REL="${f#$ROOT_DIR/}"
# Raw pointers (potential leaks)
if grep -qE '\bnew\b\s+\w' "$f" 2>/dev/null; then
warn "$REL: raw 'new' detected — prefer smart pointers"
((ISSUES++))
fi
# Missing include guards
if [[ "$ext" == "hpp" || "$ext" == "h" ]]; then
if ! grep -q '#ifndef\|#pragma once' "$f" 2>/dev/null; then
warn "$REL: missing include guard"
((ISSUES++))
fi
fi
done < <(find "$ROOT_DIR/Core" -name "*.$ext" -print0 2>/dev/null)
done
# ─── TODO/FIXME tracking ─────────────────────────────────────────
info "Tracking TODOs and FIXMEs..."
TODO_COUNT=0
while IFS= read -r -d '' f; do
REL="${f#$ROOT_DIR/}"
HITS=$(grep -nE '(TODO|FIXME|HACK|XXX):' "$f" 2>/dev/null || true)
if [[ -n "$HITS" ]]; then
while IFS= read -r line; do
printf " ${YELLOW}${RESET} %s: %s\n" "$REL" "$line"
((TODO_COUNT++))
done <<< "$HITS"
fi
done < <(find "$ROOT_DIR" -name "*.swift" -o -name "*.cpp" -o -name "*.hpp" -o -name "*.mm" -o -name "*.h" | \
grep -v CxSwiftAgent | grep -v .build | tr '\n' '\0')
if [[ "$TODO_COUNT" -gt 0 ]]; then
info "$TODO_COUNT TODO/FIXME items found"
fi
# ─── Summary ─────────────────────────────────────────────────────
echo ""
if [[ "$ISSUES" -eq 0 ]]; then
ok "Lint passed — no issues found"
else
warn "Lint found $ISSUES issue(s)"
exit 1
fi