# Code Quality Targets
# Run code quality checks and fixes

.PHONY: quality quality-check quality-fix lint format validate

quality: quality-check quality-fix

quality-check: lint validate
	@echo "✅ All quality checks passed"

quality-fix: format
	@echo "✅ Code formatting complete"

lint:
	@echo "Running linters..."
	@if command -v shellcheck >/dev/null 2>&1; then \
		find scripts -name "*.sh" -type f -exec shellcheck {} \; || true; \
	else \
		echo "⚠️  shellcheck not installed, skipping"; \
	fi
	@if command -v yamllint >/dev/null 2>&1; then \
		find . -name "*.yml" -o -name "*.yaml" | grep -v node_modules | xargs yamllint || true; \
	else \
		echo "⚠️  yamllint not installed, skipping"; \
	fi

format:
	@echo "Formatting code..."
	@if command -v shfmt >/dev/null 2>&1; then \
		find scripts -name "*.sh" -type f -exec shfmt -w -i 4 -ci -sr {} \; || true; \
	else \
		echo "⚠️  shfmt not installed, skipping"; \
	fi

validate:
	@echo "Validating configurations..."
	@./scripts/automation/validate-configs.sh || true

standardize:
	@echo "Standardizing scripts..."
	@./scripts/automation/standardize-shebangs.sh || true
	@./scripts/automation/add-error-handling.sh || true

docs:
	@echo "Generating script documentation..."
	@./scripts/automation/generate-script-docs.sh || true

setup-dev:
	@echo "Setting up development environment..."
	@./scripts/setup/dev-environment.sh || true

