Static Analysis

You need to catch configuration errors, type issues, and code quality problems before running your robot. HORUS provides horus check for project validation, horus lint for code quality, and horus fmt for consistent formatting.

When To Use This

  • Validating horus.toml and workspace configuration before building
  • Running pre-deployment checks in CI/CD pipelines
  • Catching Rust borrow checker and type errors before runtime
  • Enforcing code style with formatting and linting

Use Testing instead if you need to verify runtime behavior, not static correctness.

Use horus doctor instead if you need to check the environment (toolchains, system dependencies, SHM availability).

Prerequisites

  • A HORUS project with horus.toml
  • Rust toolchain (for Rust projects) or Python 3 (for Python projects)

Solution

Quick Start

# Validate project configuration and code
horus check

# Format all code (Rust + Python)
horus fmt

# Lint all code (clippy + ruff)
horus lint

# CI pipeline: fail on any issue
horus fmt --check && horus lint && horus check

What horus check Validates

Phase 1: Manifest Validation

Validates your horus.toml project manifest:

CheckDescription
Project nameMust be present, lowercase alphanumeric + hyphens/underscores
VersionMust be valid semver
Build fileDetects Cargo.toml (Rust) or pyproject.toml (Python)
Required fieldsEnsures all mandatory fields are present
horus check

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Phase 1: Manifest Validation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✓ Project name valid
  ✓ Version is valid semver
  ✓ Build file detected (Cargo.toml)
  ✓ Configuration valid

Phase 2: Rust Deep Check

For Rust projects, runs cargo check to verify code compiles:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Phase 2: Rust Deep Check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Running cargo check...
  ✓ Rust code compiles successfully

This catches type errors, borrow checker issues, and missing imports before runtime.

Phase 3: Python Validation

For Python projects, checks syntax and imports:

CheckDescription
SyntaxRuns py_compile on all .py files
ImportsVerifies that imported modules are available
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Phase 3: Python Validation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Checking Python files...
  ✓ main.py - syntax OK
  ✓ nodes/sensor.py - syntax OK
  ✓ All imports resolvable

Additional Checks

horus check also validates:

  • Toolchain: Verifies Rust toolchain and Python interpreter are available
  • System requirements: Checks disk space and system dependencies
  • API usage: Validates HORUS API usage patterns in project code
  • Registry connectivity: Tests connection to the HORUS package registry (if packages are declared)

Example Output

$ horus check

╔══════════════════════════════════════════╗
║         HORUS Project Check             ║
╚══════════════════════════════════════════╝

Project: my_robot (v0.1.0)
Language: python

Phase 1: Manifest ...................... ✓
Phase 2: Python Validation ............ ✓
Phase 3: System Requirements .......... ✓

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Result: All checks passed ✓
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Variations

CI/CD Pipeline

#!/bin/bash
set -e
horus fmt --check        # Fail if code is unformatted
horus lint               # Fail on lint errors
horus check --quiet      # Validate project (errors only)
horus test               # Run all tests
horus doc --coverage --fail-under 80  # Doc coverage gate

Lint Configuration

horus lint runs clippy (Rust) and ruff check (Python). Configure clippy via Cargo.toml [lints]. Configure ruff via ruff.toml or pyproject.toml [tool.ruff].

Machine-Readable Output

For CI, use horus build --json-diagnostics for machine-parseable Cargo output, or horus check --json for structured validation output.

Auto-Fix Lint Issues

# Fix what can be auto-fixed
horus lint --fix
horus fmt

CI Pipeline (Full Example)

#!/bin/bash
set -euo pipefail

# Stage 1: Static analysis
horus fmt --check              # Fail if code is unformatted
horus lint                     # Fail on lint errors
horus check --json             # Structured validation output

# Stage 2: Build and test
horus build --json-diagnostics # Machine-parseable build output
horus test                     # Run all tests

Common Errors

SymptomCauseFix
horus check fails on manifestInvalid horus.toml syntax or missing fieldsRun horus check and fix the reported issues
cargo check failsRust compilation errors (types, borrows, imports)Fix the errors shown in the output
Python syntax check failsInvalid Python syntax in .py filesFix the syntax errors shown by py_compile
horus fmt --check exits non-zeroUnformatted codeRun horus fmt to auto-format
horus lint reports warningsClippy or ruff detected anti-patternsRun horus lint --fix for auto-fixable issues, fix remaining manually

See Also