file_content_forbidden
File contents must NOT match a regex.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
pattern | string | yes | Rust 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.
Example
Section titled “Example”Source that left a debug macro in
Section titled “Source that left a debug macro in”The rule fires on this repository:
src/src/clean.rssrc/main.rspub fn ok() {}fn main() { dbg!(42);}With this .alint.yml:
version: 1rules: - id: no-dbg kind: file_content_forbidden paths: "src/**/*.rs" pattern: '\bdbg!\s*\(' level: warningalint check reports:
--- src/main.rs ---------------------------------------------------------------- ! warning no-dbg 2:1 forbidden pattern /\bdbg!\s*\(/ found
Summary (1 violation): ! 1 warning 0 passing * 1 failingSource with no forbidden macros
Section titled “Source with no forbidden macros”This repository is compliant:
src/src/clean.rssrc/main.rspub fn ok() {}fn main() { println!("hi");}With this .alint.yml:
version: 1rules: - id: no-dbg kind: file_content_forbidden paths: "src/**/*.rs" pattern: '\bdbg!\s*\(' level: warningalint check reports:
v All 1 rule(s) passed.