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 or expect_matches. This table is generated from the JSON Schema; option types and defaults are authoritative.

A C source file with no matching header

Section titled "A C source file with no matching header"

The rule fires on this repository:

  • src/
  • src/alpha.c✓
  • src/alpha.h✓
  • src/beta.c

    ✗ error c-requires-h

    src/beta.c has no matching partner at src/beta.h (template: {dir}/{stem}.h) related: expected partner: src/beta.h

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)
related: expected partner: src/beta.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.