Skip to content

pair

For every file matching primary, a file matching the partner template must exist.

OptionTypeRequiredDefaultDescription
partnerstringyesPath template resolved per primary match. Example: “{dir}/{stem}.h”.
primarystringyesGlob selecting the primary files.

Plus the common level, id, and when fields. This rule analyses the whole repository, so it takes no paths. This table is generated from the JSON Schema; option types and defaults are authoritative.

The rule fires on this repository:

src/
src/alpha.c
src/alpha.h
src/beta.c
src/alpha.c
int a;
src/alpha.h
int a;
src/beta.c
int b;

With this .alint.yml:

version: 1
rules:
- id: c-requires-h
kind: pair
primary: "src/**/*.c"
partner: "{dir}/{stem}.h"
level: error

alint check reports:

Terminal window
--- src/beta.c -----------------------------------------------------------------
x error c-requires-h
src/beta.c has no matching partner at src/beta.h (template:
{dir}/{stem}.h)
Summary (1 violation):
x 1 error
0 passing * 1 failing

Every C source file has its header partner

Section titled “Every C source file has its header partner”

This repository is compliant:

src/
src/alpha.c
src/alpha.h
src/beta.c
src/beta.h
src/alpha.c
int a;
src/alpha.h
int a;
src/beta.c
int b;
src/beta.h
int b;

With this .alint.yml:

version: 1
rules:
- id: c-requires-h
kind: pair
primary: "src/**/*.c"
partner: "{dir}/{stem}.h"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.