From ec61ab21a5bdbec1266a3813321a091cdcd2c249 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Fri, 7 Oct 2022 11:31:01 +0300 Subject: [PATCH] add contributing file + .rustfmt.toml file (#13) --- .rustfmt.toml | 7 +++++ CONTRIBUTING.md | 55 +++++++++++++++++++++++++++++++++ text-redaction/src/lib.rs | 4 +-- text-redaction/src/redaction.rs | 2 +- 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 .rustfmt.toml create mode 100644 CONTRIBUTING.md diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..ca9413f --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,7 @@ +max_width = 100 +comment_width = 80 +wrap_comments = true +imports_granularity = "Crate" +use_small_heuristics = "Default" +group_imports = "StdExternalCrate" +format_strings = true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..46c1fe0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing code to text-redaction + +Everyone is welcome to contribute code to `text-redaction`, provided that they are willing to license their contributions under the same license as the project itself. +We follow a simple 'inbound=outbound' model for contributions: the act of submitting an 'inbound' contribution means that the contributor agrees to license the code under the same terms as the project's overall 'outbound' license - in this case, Apache Software License v2 (see [LICENSE](./LICENSE)). + + +## How to contribute + +The preferred and easiest way to contribute changes to the project is to fork it on GitHub, and then create a pull request to ask us to pull your changes into our repo. + +Things that should go into your PR description: + + - References to any bugs fixed by the change + - Notes for the reviewer that might help them to understand why the change is necessary or how they might better review it + +Your PR must also: + + - be based on the `main` branch + - adhere to the [code style](#code-style) + - pass the [test suites](#tests) + + +## Tests + +In `text-redaction` we have few test suite flows that need to pass before merging to master. +- [unitest](#unitest) +- [clippy](#clippy) +- [rustfmt](#rustfmt) + +### unitest + +run the following command: +```bash +cargo xtask test +``` + +To capture the snapshots test we using [insta](https://github.com/mitsuhiko/insta) rust project. you can see the snapshot changes / new snapshot by running the command: +```bash +cargo insta test --review +``` + +### clippy +```bash +cargo xtask clippy +``` + +### rustfmt +```bash +cargo xtask clippy +``` + +## Code style + +We use the standard Rust code style, and enforce it with `rustfmt`/`cargo fmt`. +A few code style options are set in the [`.rustfmt.toml`](./.rustfmt.toml) file, and some of them are not stable yet and require a nightly version of rustfmt. \ No newline at end of file diff --git a/text-redaction/src/lib.rs b/text-redaction/src/lib.rs index 4fc1a0c..f60e0a5 100644 --- a/text-redaction/src/lib.rs +++ b/text-redaction/src/lib.rs @@ -7,9 +7,7 @@ //! ```console //! $ cargo run --example redaction_string //! ``` -//! -pub use crate::data::Pattern; -pub use crate::redaction::Redaction; +pub use crate::{data::Pattern, redaction::Redaction}; mod data; mod engine; diff --git a/text-redaction/src/redaction.rs b/text-redaction/src/redaction.rs index 1cde623..fc69ac9 100644 --- a/text-redaction/src/redaction.rs +++ b/text-redaction/src/redaction.rs @@ -191,10 +191,10 @@ impl Redaction { #[cfg(test)] mod test_redaction { - use regex::Regex; use std::{env, fs::File, io::Write}; use insta::assert_debug_snapshot; + use regex::Regex; use super::*;