guarding 0.2.1

Guarding is a guardians for code, architecture, layered. Guarding crate a architecture aguard DSL which based on ArchUnit.
Documentation

Guarding

Build crates.io docs.rs license

Guarding is a guardians for code, architecture, layered. Using git hooks and DSL for design guard rules.

todo:

  • guarding DSL design
  • setup projects
  • parser
    • tree-sitter
  • parser
  • interface / trait supports
  • languages
    • Java
    • JavaScript
    • TypeScript
    • Rust

Others:

  • ArchUnit code generator?
  • git hooks for staged files (low-priority, some-languages has custom git hooks)

Usage

  1. install
cargo install guarding
  1. create guarding.guarding file
package(".")::file.len should < 200;
package(".")::file.len should > 50;
  1. run
guarding .

Development

workflow:

  1. parsing guarding rules
  2. parsing source code to models
  3. capture rule with models

DSL capture logic:

  1. filter models from rule_level with rule_scope
  2. run expression
  3. run assert

Queries Samples: https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries

Document

Guarding - Class or Struct function-name

for Java, JavaScript

# 类::名 包含 "Controller";
# 中文分词:("..myapp..") 类名称中包含 "Controller"
class("..myapp..")::function.name should contains("Model");
# or
class("..myapp..")::function.name contains("");

for Rust and Golang

struct("..myapp..")::function.name should contains("Model");
# or
struct("..myapp..")::function.name contains("");

License

This code is distributed under the MIT license. See LICENSE in this directory.