Skip to main content

EPITA C Coding Style Checker - validates C code against EPITA coding standards

Project description

EPITA C Coding Style Checker

A fast C linter for EPITA coding style rules. Uses tree-sitter for robust AST-based parsing.

Installation

pipx install epita-coding-style

Usage

epita-coding-style <path>              # Check files/directories
epita-coding-style src/ --preset 42sh  # Use relaxed preset
epita-coding-style src/ --config style.toml  # Use config file
epita-coding-style --list-rules        # List all rules

Configuration

Default: Strict EPITA rules (30 lines max, goto/cast banned).

Settings are applied in order of priority (highest wins):

CLI flags > Config file > Preset > Defaults

This means you can start with a preset and override specific settings in your config file or via CLI.

Presets

epita-coding-style --preset 42sh src/  # Relaxed: 40 lines, goto/cast allowed

Config File

Create .epita-style (or .epita-style.toml) in your project root:

max_lines = 40

[rules]
"keyword.goto" = false
"cast" = false

Auto-detection order: .epita-style.epita-style.tomlpyproject.toml

In pyproject.toml:

[tool.epita-coding-style]
max_lines = 40

[tool.epita-coding-style.rules]
"keyword.goto" = false

Combining Preset + Config

Use a preset as a base and customize specific settings:

# .epita-style.toml
preset = "42sh"      # Start with 42sh (40 lines, goto/cast allowed)
max_lines = 50       # Override: bump to 50 lines

[rules]
"cast" = true        # Override: re-enable cast checking

CLI Options

--preset NAME   Use preset (42sh)
--config FILE   Use config file
--max-lines N   Max lines per function
--max-args N    Max args per function
--max-funcs N   Max exported functions
-q, --quiet     Summary only
--no-color      Disable colors
--list-rules    List all rules

Rules

Rule Description Default
fun.length Max lines per function body 30
fun.arg.count Max arguments per function 4
fun.proto.void Empty params should use void on
export.fun Max exported functions per file 10
export.other Max exported globals per file 1
braces Allman brace style on
decl.single One declaration per line on
decl.vla No variable-length arrays on
keyword.goto No goto statements on
cast No explicit casts on
stat.asm No asm declarations on
ctrl.empty Empty loops use continue on
file.trailing No trailing whitespace on
file.dos No CRLF line endings on
file.terminate File ends with newline on
file.spurious No blank lines at file start/end on
lines.empty No consecutive empty lines on
cpp.guard Headers need include guards on
cpp.mark # on first column on
cpp.if #endif needs comment on
cpp.digraphs No digraphs/trigraphs on
format clang-format compliance on

clang-format

The format rule uses clang-format to check code formatting. Requires clang-format to be installed.

The checker looks for .clang-format in the file's directory (walking up to root), or uses the bundled EPITA config.

To disable: set "format" = false in your config.

Pre-commit Hook

Add to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/KazeTachinuu/epita-coding-style
    rev: v2.1.0
    hooks:
      - id: epita-coding-style
        args: [--preset, 42sh]  # optional

Development

Releasing a New Version

Version is managed in pyproject.toml (single source of truth). Use uv version to bump:

uv version --bump patch   # 2.2.1 -> 2.2.2
uv version --bump minor   # 2.2.1 -> 2.3.0
uv version --bump major   # 2.2.1 -> 3.0.0
# or set explicitly:
uv version 2.3.0

Then commit, tag, and push:

git add pyproject.toml uv.lock
git commit -m "Bump version to X.Y.Z"
git tag vX.Y.Z
git push origin master && git push origin vX.Y.Z

The CI will automatically publish to PyPI when a tag is pushed.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epita_coding_style-2.2.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epita_coding_style-2.2.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file epita_coding_style-2.2.1.tar.gz.

File metadata

  • Download URL: epita_coding_style-2.2.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for epita_coding_style-2.2.1.tar.gz
Algorithm Hash digest
SHA256 bdc470117f9c0c1d3cfffe4dc731236b73768a76d2468ec2974e872f60cd89aa
MD5 69cb2e12ee3f68036aaf36d6516db376
BLAKE2b-256 2d17f7abab079cc94c82bb9729069af8e082a3de1aa803a616c23cd2951fcf3e

See more details on using hashes here.

File details

Details for the file epita_coding_style-2.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for epita_coding_style-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7426e2f3922b1a7d4d9ddec8c7a6c93a606f16d1b88b112acf5474f0648dca2b
MD5 5a673b7271fcec255692c5608a4db370
BLAKE2b-256 8e922b8e15fb68d8fe2e45d422c69ad4cae16b724fe17960aee451cff71258ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page