Norminette v4.1 for 42 Lisboa
  • Python 63%
  • TeX 18.2%
  • C 17.5%
  • Shell 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
kontebria 4f122ce495
All checks were successful
CI / debian (push) Successful in 1m0s
CI / fedora (push) Successful in 1m2s
CI / leap (push) Successful in 55s
CI / opensuse (push) Successful in 1m7s
CI / python 3.10 (push) Successful in 1m3s
CI / python 3.13 (push) Successful in 50s
CI / ubuntu (push) Successful in 52s
Remove dead code and duplication, update the docs
- Rules that did nothing any more (CheckDeclaration, CheckEnumVarDecl,
  CheckInHeader, CheckStructNaming), unused methods, constants, counters
  and commented-out code, and 13 error codes nothing reported.
- One shared name check (norminette/naming.py); File.lines splits the
  source once per file.
- Fix a crash when the tabs before a function name reach the start of
  the file.
- Golden files: one render function for the test and for
  `python -m tests.rules.regenerate`.
- CI: one matrix, steps shared with container-ci.sh (--steps).
- Issue and PR templates moved to .forgejo/ and written for this fork;
  the upstream CONTRIBUTING.md and the v3/v4 Norm translations are gone.
- Translations for the three messages this fork added.
- BUILDING, COVERAGE and CHANGELOG brought up to date.

Same output as before on the test suite and on 4,494 generated files,
except the crash case.
2026-11-18 12:27:50 +00:00
.forgejo Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
docs Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
norminette Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
pdf Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
staff_report Audit every check against the Norm v4.1 text (4.1.2) and a second pass 2026-11-18 08:40:32 +00:00
tests Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
.flake8 Import 42school/norminette 3.3.60 (upstream commit 25752ee) as baseline 2026-10-24 08:05:14 +01:00
.gitignore Apply the Norm v4.1 adaptation layer (norminette 4.1.1) 2026-10-24 08:11:17 +01:00
action.yml Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
CHANGELOG.md Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
container-ci.sh Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
CREDITS.md CREDITS: shorter note on AI assistance, more thanks 2026-11-18 12:12:54 +00:00
Dockerfile Import 42school/norminette 3.3.60 (upstream commit 25752ee) as baseline 2026-10-24 08:05:14 +01:00
install.sh Apply the Norm v4.1 adaptation layer (norminette 4.1.1) 2026-10-24 08:11:17 +01:00
LICENSE Import 42school/norminette 3.3.60 (upstream commit 25752ee) as baseline 2026-10-24 08:05:14 +01:00
norm-v4.1.txt Apply the Norm v4.1 adaptation layer (norminette 4.1.1) 2026-10-24 08:11:17 +01:00
pyproject.toml Remove dead code and duplication, update the docs 2026-11-18 12:27:50 +00:00
README.md Audit every check against the Norm v4.1 text (4.1.2) and a second pass 2026-11-18 08:40:32 +00:00
run_test.sh Audit every check against the Norm v4.1 text (4.1.2) and a second pass 2026-11-18 08:40:32 +00:00
uv.lock Audit every check against the Norm v4.1 text (4.1.2) and a second pass 2026-11-18 08:40:32 +00:00

norminette for the Norm v4.1

At 42, every C file you hand in has to follow the Norm: the school's coding standard (25-line functions, tabs, s_/t_ prefixes, no for, and so on). The norminette is the program that checks it.

This project is a norminette that checks the current version of the Norm, v4.1 — exactly what the document says, nothing more and nothing less.

$ norminette main.c
main.c: Error!
Error: NON_CONST_STATIC_GLOBAL (line:  13, col:   1):  global variables must be declared as const or static
Error: TERNARY_FBIDDEN         (line:  21, col:   9):  Ternaries are forbidden

A file that follows the Norm prints main.c: OK!.

Why it exists

The official norminette (42school/norminette, 3.3.60) was written for the older Norm v3. Compared with the v4.1 document, it:

  • misses rules the Norm has, such as globals that must be const or static, snake_case file names, or the header guard every .h needs;
  • reports things the Norm doesn't forbid, such as labels, enums in a .c file, or a missing space inside parentheses;
  • gets some valid code wrong, such as unsigned i; read as an implicit type.

This project starts from the official code and fixes that, one rule of the document at a time. Where the two disagree, it follows the document.

Before you rely on it

Evaluations at 42 use the official norminette. Because this one follows the document instead, a file can pass here and fail there, or the other way around. Use this tool to learn and check the Norm as written, and run the official one before an evaluation.

Every known difference is listed, with a small example file for each, in the staff report. That report also collects the places where the Norm itself is unclear, as questions for the 42 staff, with what this tool does in the meantime.

What it checks

Every rule of the Norm that a program can check:

  • naming: s_, t_, u_, e_, g_ prefixes, lowercase identifiers, file and folder names, no non-ASCII characters outside strings;
  • formatting: 25 lines per function, 80 columns, tabs, braces, spacing, empty lines, declarations at the top and aligned, one instruction per line;
  • functions: at most 4 named parameters and 5 variables, void for no parameters, named prototype parameters, return (value);;
  • types: struct, enum, union and typedef layout, no structure in a .c file;
  • headers and files: include guards named after the file, includes first, no .c includes, the 42 header, at most 5 functions per .c file;
  • macros: uppercase names, one line each, indented inside #if blocks, only at global scope;
  • forbidden constructs: for, do...while, switch, case, goto, ternaries, variable-length arrays, implicit types;
  • comments: none inside function bodies.

The Norm marks some rules with (*) to say a person checks them: whether names are meaningful, comments useful, headers up to date, includes needed. This tool leaves those to the evaluator, as the Norm intends. The Makefile rules aren't checked either; the Norm says so itself.

The full rule-by-rule table, with the error code for each rule, is in docs/COVERAGE.md.

Install

You need Python 3.10 or newer, and nothing else.

sh install.sh                # install, or update
sh install.sh --uninstall    # remove

It installs into your home folder (no root needed) and puts norminette on your PATH. pip install ., uv tool install . and the Dockerfile work too; see docs/BUILDING.md.

Use

norminette                   # every .c and .h file under this folder
norminette main.c src/       # some files or folders
norminette --format json     # output for scripts
norminette --allow-globals   # for projects that allow plain globals
norminette -v                # version

The exit code is 0 when every file is OK, so it fits in scripts and CI.

For contributors

sh run_test.sh               # the whole test suite
  • docs/BUILDING.md: installing on each distro, tests, CI, translations, and updating to a newer official version
  • docs/COVERAGE.md: each rule of the Norm and how it's checked
  • CHANGELOG.md: what changed compared with the official norminette
  • staff_report/: differences with the official tool, and questions for the staff

License and credits

MIT. The engine is the work of the 42 Association and the norminette contributors; see LICENSE and CREDITS.md, which also explains how AI tools were used in this project.