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.2.0.tar.gz (15.6 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.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: epita_coding_style-2.2.0.tar.gz
  • Upload date:
  • Size: 15.6 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.0.tar.gz
Algorithm Hash digest
SHA256 025face584c6331afffc826becb5ec88111eb635e4b0db1209be57aaa5250353
MD5 7fc8759f9b51809dcb0a876017a7f7ba
BLAKE2b-256 4eff65a5f11e48925a22a6c47d3eb9462987b558c00cc14a346ff7db63a24d58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for epita_coding_style-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 102dc22648e85570d69e20cdea6b9856dd06418fe6c1ee5501f04cb7f81b8596
MD5 1c20d2862dba7735178a341175b30dc0
BLAKE2b-256 2aae592e53dc392f3295f0010e8a3f8876805a8b4ec5614904664992ee80fde4

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