Skip to main content

Module explain_examples

Module explain_examples 

Source
Expand description

The example project of each rule: a small project that makes the rule report a finding.

The files are in crates/api/rule-examples/<rule>/, where <rule> is the rule id without its namespace prefix:

  • files/ holds the project. For a rule of the audit command, it holds the project after the change.
  • base/ holds the project before the change. Only an audit rule has it. A file of base/ that files/ does not have stays as it is.
  • example.json is optional. args are the arguments after the command that the finding needs. hidden lists the files that a reader does not need to understand the finding, such as a plain package.json.

explain_examples_table.rs embeds the files. The CLI integration test rule_example_tests runs fallow on each project and checks that the rule reports it, so an example cannot go stale.

Structs§

ExampleFile
One file of an example project.
RuleExample
The example project of one rule.

Functions§

rule_example
The example project of rule. None when the rule needs data that a small project does not have, such as production runtime data.
rule_examples
Every example project, in order of rule id.