Skip to content

file_content_forbidden

File contents must NOT match a regex.

OptionTypeRequiredDefaultDescription
patternstringyesRust regex. File contents must NOT match.

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

The rule fires on this repository:

src/
src/clean.rs
src/main.rs
src/clean.rs
pub fn ok() {}
src/main.rs
fn main() {
dbg!(42);
}

With this .alint.yml:

version: 1
rules:
- id: no-dbg
kind: file_content_forbidden
paths: "src/**/*.rs"
pattern: '\bdbg!\s*\('
level: warning

alint check reports:

Terminal window
--- src/main.rs ----------------------------------------------------------------
! warning no-dbg
2:1 forbidden pattern /\bdbg!\s*\(/ found
Summary (1 violation):
! 1 warning
0 passing * 1 failing

This repository is compliant:

src/
src/clean.rs
src/main.rs
src/clean.rs
pub fn ok() {}
src/main.rs
fn main() {
println!("hi");
}

With this .alint.yml:

version: 1
rules:
- id: no-dbg
kind: file_content_forbidden
paths: "src/**/*.rs"
pattern: '\bdbg!\s*\('
level: warning

alint check reports:

Terminal window
v All 1 rule(s) passed.