Skip to content

file_footer

The configured number of final lines in each file in scope must match a regex. Mirror of file_header anchored at the end of the file. Use for license footers, signed-off-by trailers, generated-file sentinels.

As in file_header, the lines are one string, newlines included, so $ matches only after the final newline: end a pattern with \s*$, or use (?m), to match the last line. See Regex patterns and anchors.

Fix: file_append — append a declared content. With no fix declared, violations are unfixable.

OptionTypeRequiredDefaultDescription
linesinteger (>= 1)20Number of trailing lines to consider.
patternstringyesRust regex. The last lines lines of each file must match. They are one string, newlines included, so ^ and $ anchor to the block's start and end unless the pattern turns on (?m).

Plus the common paths, level, id, when, scope_filter, fix, and expect_matches fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

The rule fires on this repository:

  • src/
  • src/missing.rs

    ⚠ warning license-footer

    last 3 line(s) do not match required footer /Licensed under the Apache License/

  • src/ok.rs✓
src/missing.rs
fn b() {}
// no footer here
src/ok.rs
fn a() {}
// Licensed under the Apache License, Version 2.0

With this .alint.yml:

version: 1
rules:
- id: license-footer
kind: file_footer
paths: "src/**/*.rs"
pattern: "Licensed under the Apache License"
lines: 3
level: warning

alint check reports:

Terminal window
--- src/missing.rs -------------------------------------------------------------
! warning license-footer
last 3 line(s) do not match required footer /Licensed under the
Apache License/
Summary (1 violation):
! 1 warning
0 passing * 1 failing
Section titled "Every file ends with the license footer"

This repository is compliant:

  • src/
  • src/a.rs✓
  • src/b.rs✓
src/a.rs
fn a() {}
// Licensed under the Apache License, Version 2.0
src/b.rs
fn b() {}
// Licensed under the Apache License, Version 2.0

With this .alint.yml:

version: 1
rules:
- id: license-footer
kind: file_footer
paths: "src/**/*.rs"
pattern: "Licensed under the Apache License"
lines: 3
level: warning

alint check reports:

Terminal window
v All 1 rule(s) passed.