Skip to content

Commit 86b5230

Browse files
committed
Add configuration examples to README.md
1 parent ae51dc3 commit 86b5230

1 file changed

Lines changed: 64 additions & 3 deletions

File tree

README.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,74 @@ A configuration file allows one to tailor Necessist's behavior with respect to a
423423

424424
- `ignored_functions`, `ignored_methods`, `ignored_macros`: A list of strings interpreted as [patterns]. A function, method, or macro (respectively) whose [path] matches a pattern in the list is ignored. Note that `ignored_macros` is used only by the Rust backend currently.
425425

426+
<details>
427+
428+
<summary><code>ignored_functions</code> Rust example</summary>
429+
430+
In the [`valid_pattern` fixture]'s [`necessist.toml` file], disabling the use of `ignored_functions` would make the following a candidate for removal:
431+
432+
```
433+
fixtures/valid_pattern/src/lib.rs:68:5-68:38: `ignored_function(foo().method());`
434+
```
435+
436+
</details>
437+
438+
<details>
439+
440+
<summary><code>ignored_methods</code> Rust example</summary>
441+
442+
In the [`valid_pattern` fixture]'s [`necessist.toml` file], disabling the use of `ignored_methods` would make the following candidates for removal:
443+
444+
```
445+
fixtures/valid_pattern/srclib.rs:60:5-60:26: `bar.ignored_method();`
446+
fixtures/valid_pattern/srclib.rs:65:5-65:32: `bar.field.ignored_method();`
447+
fixtures/valid_pattern/srclib.rs:55:10-55:27: `.ignored_method()`
448+
fixtures/valid_pattern/srclib.rs:56:10-56:27: `.ignored_method()`
449+
fixtures/valid_pattern/srclib.rs:60:8-60:25: `.ignored_method()`
450+
fixtures/valid_pattern/srclib.rs:61:8-61:25: `.ignored_method()`
451+
fixtures/valid_pattern/srclib.rs:65:8-65:31: `.field.ignored_method()`
452+
fixtures/valid_pattern/srclib.rs:66:8-66:31: `.field.ignored_method()`
453+
```
454+
455+
</details>
456+
457+
<details>
458+
459+
<summary><code>ignored_macros</code> Rust example</summary>
460+
461+
In the [`valid_pattern` fixture]'s [`necessist.toml` file], disabling the use of `ignored_macros` would make the following a candidate for removal:
462+
463+
```
464+
fixtures/valid_pattern/src/lib.rs:49:5-49:18: `say_hello!();`
465+
```
466+
467+
</details>
468+
469+
<p></p>
470+
426471
- `ignored_path_disambiguation`: One of the strings `Either`, `Function`, or `Method`. For a [path] that could refer to a function or method ([see below](#paths)), this option influences whether the function or method is ignored.
427-
- `Either` (default): Ignore if the path matches either an `ignored_functions` or `ignored_methods` pattern.
428-
- `Function`: Ignore only if the path matches an `ignored_functions` pattern.
429-
- `Method`: Ignore only if the path matches an `ignored_methods` pattern.
472+
- `ignored_path_disambiguation = "None"` (default): Ignore if the path matches either an `ignored_functions` or `ignored_methods` pattern.
473+
- `ignored_path_disambiguation = "Function"`: Ignore only if the path matches an `ignored_functions` pattern.
474+
- `ignored_path_disambiguation = "Method"`: Ignore only if the path matches an `ignored_methods` pattern.
430475

431476
- `ignored_tests`: A list of strings. A test whose name exactly matches a string in the list is ignored. For Mocha-based frameworks (e.g., Anchor and Hardhat), a test name is considered to be a message passed to `it`.
432477

433478
- `visit_ignored_arguments`: A boolean indicating whether Necessist should visit the arguments of ignored functions, methods, and macros. The default is `false`.
434479

480+
<details>
481+
482+
<summary>Rust example</summary>
483+
484+
In the [`valid_pattern` fixture]'s [`necessist.toml` file], disabling the use of `visit_ignored_arguments` would make the following no longer a candidate for removal:
485+
486+
```
487+
fixtures/valid_pattern/src/lib.rs:68:27-68:36: `.method()` passed
488+
```
489+
490+
</details>
491+
492+
<p></p>
493+
435494
- `walkable_functions`: A list of strings interpreted as [patterns]. If a test calls a function that matches the pattern, and the function is declared in the same file as the test, then statements and method calls are removed from the function as though it were a test.
436495

437496
### Patterns
@@ -514,6 +573,7 @@ Necessist is licensed and distributed under the AGPLv3 license. [Contact us](mai
514573
[`assert_cmd::assert::Assert::success`]: https://docs.rs/assert_cmd/latest/assert_cmd/assert/struct.Assert.html#method.success
515574
[`fixtures/basic`]: https://github.com/trailofbits/necessist/tree/master/fixtures/basic
516575
[`glob`]: https://man7.org/linux/man-pages/man7/glob.7.html
576+
[`necessist.toml` file]: https://github.com/trailofbits/necessist/tree/master/fixtures/valid_pattern/necessist.toml
517577
[`rust-openssl`]: https://github.com/sfackler/rust-openssl
518578
[`std::borrow::Cow::into_owned`]: https://doc.rust-lang.org/std/borrow/enum.Cow.html#method.into_owned
519579
[`std::clone::Clone::clone`]: https://doc.rust-lang.org/std/clone/trait.Clone.html#tymethod.clone
@@ -526,6 +586,7 @@ Necessist is licensed and distributed under the AGPLv3 license. [Contact us](mai
526586
[`testing.T`]: https://pkg.go.dev/testing#T
527587
[`universalmutator`]: https://github.com/agroce/universalmutator
528588
[`unnecessary_conversion_for_trait`]: https://github.com/trailofbits/dylint/tree/master/examples/supplementary/unnecessary_conversion_for_trait
589+
[`valid_pattern` fixture]: https://github.com/trailofbits/necessist/tree/master/fixtures/valid_pattern/src/lib.rs
529590
[added to the test]: https://github.com/sfackler/rust-openssl/pull/1852
530591
[crates.io]: https://crates.io/crates/necessist
531592
[frameworks besides Hoare logic entirely]: https://github.com/trailofbits/necessist/pull/474#discussion_r1230859226

0 commit comments

Comments
 (0)