2 Star 4 Fork 1

Thoughtworks / guarding

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Guarding

Build crates.io docs.rs license

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

Guarding Process

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

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("");

Todos

todo:

  • filter
    • filter by package identifier
    • filter by regex
    • filter by implementation
    • filter by extends
    • filter by trait
  • limit impl naming
  • limit files num
  • limit package's sub-package size (for example, Clean Architecture).
  • assert
    • comparison for size / len
    • string comparison
      • contains
      • startsWith
      • endsWith
    • package ops
      • accessed
      • resideIn
      • dependBy
  • languages
    • Java
    • JavaScript (on Going)
    • TypeScript
    • Rust (on Going)
      • class & functions
      • imports
        • basic import
        • mods import restructure
      • package convert

License

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

MIT License Copyright (c) 2021 Inherd Group Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Guarding 是一个用于 Java、JavaScript、Rust、Golang 等语言的架构守护工具。借助于易于理解的 DSL,来编写守护规则。 展开 收起
Rust 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Rust
1
https://gitee.com/thoughtworks/guarding.git
git@gitee.com:thoughtworks/guarding.git
thoughtworks
guarding
guarding
master

搜索帮助