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).

Presets

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

Config File

Create .epita-style.toml in your project root:

max_lines = 40
max_args = 4
max_funcs = 10

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

Or in pyproject.toml:

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

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

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

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.1.0.tar.gz (14.2 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.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: epita_coding_style-2.1.0.tar.gz
  • Upload date:
  • Size: 14.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 40f58bdf7e1d873ae341d28c9c278c1614324e8de77c6eac00a40704f0ac8b52
MD5 eb16563c7ccbaffee33f75e3a3f7c94c
BLAKE2b-256 fd6d84f1e0d7082b8c803469d2276e838d0a32b9d7d11f715f35a19d67ba2a8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for epita_coding_style-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 359e5e10b810fc7cc65d9e9a6a62a276a017ce53d220bca77c663c2f74715b06
MD5 8a507a51eebc78c39bd91c0c10568281
BLAKE2b-256 270d3ca91c2a132a87c45a51aa6e6395f1e1120abfb8bd0d35c23cd05ecd3976

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