diff --git a/README.md b/README.md index 727d960..d525415 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,7 @@ project runs again, so they are never ticked for you. | Swift Package Manager | `.build` | | | Xcode (CocoaPods) | | `Pods` | | .NET | `bin` `obj` | | +| Elixir (Mix) | `_build` | `deps` | | PHP (Composer) | | `vendor` | Add your own rules in `~/Library/Application Support/OpenSweep/rules`, or keep a diff --git a/docs/RULE-SCHEMA.md b/docs/RULE-SCHEMA.md index 785f208..8f8a744 100644 --- a/docs/RULE-SCHEMA.md +++ b/docs/RULE-SCHEMA.md @@ -106,6 +106,8 @@ rules. ## Contributing a rule 1. Add or edit a file in `engine/rules/`, with match and nomatch fixtures. + A new file also goes in `BUNDLED` in `opensweep-core/src/rules.rs`, which + builds the catalogue into the binary. 2. Run `cargo run -p opensweep-cli -- rules-check rules` and `cargo test`. 3. In the pull request, link the tool's documentation that says the path is generated. Rule changes need two reviewers. diff --git a/engine/crates/opensweep-cli/tests/snapshots/rules-check.json b/engine/crates/opensweep-cli/tests/snapshots/rules-check.json index 1fa6d40..1e5e20d 100644 --- a/engine/crates/opensweep-cli/tests/snapshots/rules-check.json +++ b/engine/crates/opensweep-cli/tests/snapshots/rules-check.json @@ -1,8 +1,8 @@ [ { - "artifacts": 32, + "artifacts": 34, "command": "rules-check", - "rule_files": 11, + "rule_files": 12, "schema_version": 1 } ] diff --git a/engine/crates/opensweep-core/src/rules.rs b/engine/crates/opensweep-core/src/rules.rs index 1cf36f7..0b11f6c 100644 --- a/engine/crates/opensweep-core/src/rules.rs +++ b/engine/crates/opensweep-core/src/rules.rs @@ -577,6 +577,7 @@ pub fn load_dir(dir: &Path) -> Result, RuleError> { const BUNDLED: &[(&str, &str)] = &[ ("android.toml", include_str!("../../../rules/android.toml")), ("dotnet.toml", include_str!("../../../rules/dotnet.toml")), + ("elixir.toml", include_str!("../../../rules/elixir.toml")), ("flutter.toml", include_str!("../../../rules/flutter.toml")), ("go.toml", include_str!("../../../rules/go.toml")), ("java.toml", include_str!("../../../rules/java.toml")), diff --git a/engine/rules/elixir.toml b/engine/rules/elixir.toml new file mode 100644 index 0000000..4f658a3 --- /dev/null +++ b/engine/rules/elixir.toml @@ -0,0 +1,21 @@ +schema = 2 +id = "elixir" +name = "Elixir (Mix)" + +# Defaults from https://hexdocs.pm/mix/Mix.Project.html: build_path +# "defaults to _build" and deps_path "Defaults to deps". An umbrella's apps +# share the umbrella's folders, so only the top mix.exs has them. +[detect] +any_files = ["mix.exs"] + +[[artifact]] +path = "_build" +class = "safe" +reason = "Mix build output. Recreated by the next compile." +restore = "mix compile" + +[[artifact]] +path = "deps" +class = "caution" +reason = "Mix dependencies. Fetch them again from mix.lock." +restore = "mix deps.get" diff --git a/engine/rules/fixtures/elixir/match/app/_build/dev/lib/.keep b/engine/rules/fixtures/elixir/match/app/_build/dev/lib/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/match/app/deps/jason/mix.exs b/engine/rules/fixtures/elixir/match/app/deps/jason/mix.exs new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/match/app/expected.txt b/engine/rules/fixtures/elixir/match/app/expected.txt new file mode 100644 index 0000000..0304f65 --- /dev/null +++ b/engine/rules/fixtures/elixir/match/app/expected.txt @@ -0,0 +1,2 @@ +_build +deps diff --git a/engine/rules/fixtures/elixir/match/app/lib/app.ex b/engine/rules/fixtures/elixir/match/app/lib/app.ex new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/match/app/mix.exs b/engine/rules/fixtures/elixir/match/app/mix.exs new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/nomatch/no-mix-file/README.md b/engine/rules/fixtures/elixir/nomatch/no-mix-file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/nomatch/no-mix-file/_build/.keep b/engine/rules/fixtures/elixir/nomatch/no-mix-file/_build/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/elixir/nomatch/no-mix-file/deps/.keep b/engine/rules/fixtures/elixir/nomatch/no-mix-file/deps/.keep new file mode 100644 index 0000000..e69de29