2025-11-06 10:52:59 +01:00

2.1 KiB

Clean Code Philosophy

Code Formatting and Linting with Ruff

The code in the Wazuh Virtual Machines repository must remain clean, well-formatted, and compliant with modern industry standards. To achieve this, we use Ruff for both formatting and linting.

Below are the commands to apply Ruff, depending on the scope and method you prefer:


Code Formatting

Format all Wazuh Virtual Machines code

  • Using Hatch:

    hatch run dev:ruff-format
    
  • Using the command line:

    ruff format .
    
  • Using Hatch:

    hatch run dev-ami-configurer:ruff-format
    
  • Using the command line:

    ruff format configurer/ami tests/test_configurer/test_ami
    
  • Using Hatch:

    hatch run dev-ova-pre-configurer:ruff-format
    hatch run dev-ova-post-configurer:ruff-format
    
  • Using the command line:

    ruff format configurer/ova tests/test_configurer/test_ova
    

Code Linting

Lint all Wazuh Virtual Machines code

  • Using Hatch:

    hatch run dev:ruff-lint
    
  • Using the command line:

    ruff check --fix --unsafe-fixes .
    
  • Using Hatch:

    hatch run dev-ami-configurer:ruff-lint
    
  • Using the command line:

    ruff check --fix --unsafe-fixes configurer/ami tests/test_configurer/test_ami
    
  • Using Hatch:

    hatch run dev-ova-pre-configurer:ruff-lint
    hatch run dev-ova-post-configurer:ruff-lint
    
  • Using the command line:

    ruff check --fix --unsafe-fixes configurer/ova tests/test_configurer/test_ova
    

Combined Formatting and Linting (with Hatch only)

Format and lint all Wazuh Virtual Machines code

hatch run dev:fix
hatch run dev-ami-configurer:fix
hatch run dev-ova-pre-configurer:fix
hatch run dev-ova-post-configurer:fix