.PHONY: help fmt clippy check test build release clean
.PHONY: pre-commit all
.PHONY: cognitive errors complexity
.PHONY: docs module-structure controlflow
.PHONY: install
.DEFAULT_GOAL := help
COLOR_RESET := $(shell tput sgr0)
COLOR_BOLD := $(shell tput bold)
COLOR_GREEN := $(shell tput setaf 2)
COLOR_YELLOW := $(shell tput setaf 3)
COLOR_BLUE := $(shell tput setaf 4)
SCRIPTS_DIR := scripts
help:
@printf "%bAvailable targets:%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "; green="$(COLOR_GREEN)"; reset="$(COLOR_RESET)"}; {printf " %s%-20s%s %s\n", green, $$1, reset, $$2}'
@printf "\n"
fmt:
@printf "%bFormatting code...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo fmt --all
clippy:
@printf "%bRunning clippy...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo clippy --all-targets --all-features -- -D warnings
check:
@printf "%bChecking compilation...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo check
test:
@printf "%bRunning tests...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo test -- --test-threads=1
test-ignored:
@printf "%bRunning ignored tests...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo test -- --ignored --test-threads=1
build:
@printf "%bBuilding debug version...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo build
release:
@printf "%bBuilding release version...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo build --release
install:
@printf "%bInstalling binary...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo install --path .
pre-commit: fmt clippy check test
@printf "%b✓ All pre-commit checks passed!%b\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
all: pre-commit
cognitive:
@printf "%bRunning cognitive complexity analysis...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/clippy_cognitive_complexity.sh
errors:
@printf "%bAnalyzing clippy errors...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/clippy_errors.sh
complexity:
@printf "%bGenerating complexity report...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/complexity_report.sh
docs:
@printf "%bGenerating documentation...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/generate_docs.sh
docs-open: docs
@printf "%bOpening documentation...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo doc --open
module-structure:
@printf "%bGenerating module structure...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/module_structure.sh
controlflow:
@printf "%bGenerating control flow diagram...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@bash $(SCRIPTS_DIR)/generate_controlflow_diagram.sh
clean:
@printf "%bCleaning build artifacts...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
cargo clean
clean-all: clean
@printf "%bCleaning all generated files...%b\n" "$(COLOR_BLUE)" "$(COLOR_RESET)"
@rm -rf target/
@rm -f $(SCRIPTS_DIR)/*.txt
@rm -rf $(SCRIPTS_DIR)/Modules/
quality: cognitive errors complexity
@printf "%b✓ Quality analysis complete!%b\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
analysis: quality
full-check: pre-commit quality
@printf "\n"
@printf "%b═══════════════════════════════════════════════════════════════%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "%b Full Check Summary%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "%b═══════════════════════════════════════════════════════════════%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "\n"
@printf "%bPre-commit Checks:%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf " %b✓%b Formatting (cargo fmt --all)\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf " %b✓%b Linting (cargo clippy --all-targets --all-features)\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf " %b✓%b Compilation (cargo check)\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf " %b✓%b Tests (cargo test -- --test-threads=1)\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf "\n"
@printf "%bQuality Analysis:%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf " %b✓%b Cognitive Complexity Analysis\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf " %b✓%b Clippy Errors Analysis\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf " %b✓%b Code Complexity Report\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf "\n"
@printf "%b═══════════════════════════════════════════════════════════════%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "%b✓ All checks passed successfully!%b\n" "$(COLOR_GREEN)" "$(COLOR_RESET)"
@printf "%b═══════════════════════════════════════════════════════════════%b\n" "$(COLOR_BOLD)" "$(COLOR_RESET)"
@printf "\n"