Skip to content

Commit

Permalink
add contributing file + .rustfmt.toml file (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad authored Oct 7, 2022
1 parent 9eadfa8 commit ec61ab2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 1 addition & 3 deletions text-redaction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion text-redaction/src/redaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down

0 comments on commit ec61ab2

Please sign in to comment.