From bb5d99399bc8add8308921a351520a982c98067c Mon Sep 17 00:00:00 2001 From: Nicholas Hart Date: Fri, 26 Sep 2025 14:00:09 -0700 Subject: [PATCH 1/2] removed --use-stdin-paths from swiftlint pre-commit hook invocation --- scripts/pre-commit.sh | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh index e6b32ed..29d1bc5 100755 --- a/scripts/pre-commit.sh +++ b/scripts/pre-commit.sh @@ -36,13 +36,13 @@ echo # Function to check if tools are available check_tools() { local missing_tools=() - + for tool in swiftformat swiftlint; do if ! command_exists "$tool"; then missing_tools+=("$tool") fi done - + if [[ ${#missing_tools[@]} -gt 0 ]]; then log_warning "Missing tools: ${missing_tools[*]}" log_info "Install with: brew bundle install" @@ -54,9 +54,9 @@ check_tools() { # Run SwiftFormat on staged files run_swiftformat() { log_info "📝 Running SwiftFormat..." - + local format_failed=false - + if $AUTO_FIX; then # Format staged files echo "$staged_files" | while read -r file; do @@ -64,18 +64,18 @@ run_swiftformat() { swiftformat "$file" fi done - + # Check if any files were modified local modified_files modified_files=$(echo "$staged_files" | xargs git diff --name-only 2>/dev/null || true) - + if [[ -n "$modified_files" ]]; then log_info "SwiftFormat made changes to:" echo "$modified_files" | sed 's/^/ • /' - + # Re-stage the formatted files echo "$modified_files" | xargs git add - + log_success "Formatted files re-staged for commit" else log_success "No formatting changes needed" @@ -90,7 +90,7 @@ run_swiftformat() { fi fi done - + if [[ -n "$format_issues" ]]; then log_error "SwiftFormat issues found in: $format_issues" log_info "Fix with: ./scripts/format.sh --fix" @@ -99,7 +99,7 @@ run_swiftformat() { log_success "SwiftFormat check passed" fi fi - + if $format_failed; then return 1 fi @@ -108,18 +108,18 @@ run_swiftformat() { # Run SwiftLint on staged files run_swiftlint() { log_info "🔍 Running SwiftLint..." - + local lint_failed=false local temp_file=$(mktemp) - + # Create temporary file with staged file list echo "$staged_files" > "$temp_file" - - if swiftlint lint --use-stdin-paths < "$temp_file" 2>&1; then + + if swiftlint lint < "$temp_file" 2>&1; then log_success "SwiftLint check passed" else local exit_code=$? - + if $ALLOW_WARNINGS && [[ $exit_code -eq 2 ]]; then log_warning "SwiftLint found warnings (allowing commit)" else @@ -128,9 +128,9 @@ run_swiftlint() { lint_failed=true fi fi - + rm -f "$temp_file" - + if $lint_failed; then return 1 fi @@ -139,9 +139,9 @@ run_swiftlint() { # Check for common issues run_basic_checks() { log_info "✅ Running basic checks..." - + local issues=() - + # Check for TODO/FIXME in staged files (informational) local todo_count=0 echo "$staged_files" | while read -r file; do @@ -153,11 +153,11 @@ run_basic_checks() { fi fi done - + if [[ $todo_count -gt 0 ]]; then log_info "Found TODO/FIXME comments in $todo_count file(s) (informational)" fi - + # Check for debug prints (warning) local debug_prints=() echo "$staged_files" | while read -r file; do @@ -167,33 +167,33 @@ run_basic_checks() { fi fi done - + if [[ ${#debug_prints[@]} -gt 0 ]]; then log_warning "Found print() statements in:" printf '%s\n' "${debug_prints[@]}" | sed 's/^/ • /' log_info "Consider removing debug prints before committing" fi - + log_success "Basic checks completed" } # Main execution main() { check_tools - + local checks_failed=false - + # Run all checks if ! run_swiftformat; then checks_failed=true fi - + if ! run_swiftlint; then checks_failed=true fi - + run_basic_checks - + echo if $checks_failed; then log_error "❌ Pre-commit checks failed" From 3f39a0749c81ee4ae5bddb8749111ab008f988d6 Mon Sep 17 00:00:00 2001 From: Nicholas Hart Date: Fri, 26 Sep 2025 14:10:42 -0700 Subject: [PATCH 2/2] fix forced unwrap of XCUIApplication --- scripts/setup.sh | 26 ++++++++++++++++++++++++++ templates/.swiftlint.yml.template | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 9b5aee0..d769dd6 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1152,6 +1152,31 @@ Generated iOS project using SwiftProjectTemplate with: fi } +cleanup_template_files() { + log_info "Cleaning up template-specific files..." + + # Remove template-validation.yml workflow since this is now a generated project + local template_validation_workflow=".github/workflows/template-validation.yml" + if [[ -f "$template_validation_workflow" ]]; then + rm "$template_validation_workflow" + log_success "Removed template-validation.yml (not needed for generated projects)" + fi + + # Remove empty .github/workflows directory if it has no other workflows + local workflows_dir=".github/workflows" + if [[ -d "$workflows_dir" && -z "$(ls -A "$workflows_dir" 2>/dev/null)" ]]; then + rmdir "$workflows_dir" + log_info "Removed empty workflows directory" + fi + + # Remove empty .github directory if it has no other content + local github_dir=".github" + if [[ -d "$github_dir" && -z "$(ls -A "$github_dir" 2>/dev/null)" ]]; then + rmdir "$github_dir" + log_info "Removed empty .github directory" + fi +} + display_next_steps() { log_success "🎉 Project setup complete!" echo @@ -1211,6 +1236,7 @@ main() { verify_or_create_git_repository setup_git_hooks create_initial_commit + cleanup_template_files display_next_steps } diff --git a/templates/.swiftlint.yml.template b/templates/.swiftlint.yml.template index 872a7ce..25b5fb4 100644 --- a/templates/.swiftlint.yml.template +++ b/templates/.swiftlint.yml.template @@ -82,7 +82,7 @@ cyclomatic_complexity: nesting: type_level: warning: 3 - statement_level: + function_level: warning: 5 identifier_name: