go-ruleguard

Define and run pattern-based custom linting rules.

Github星跟蹤圖

go-ruleguard

Build Status
GoDoc
Go Report Card

Logo

Overview

analysis-based Go linter that runs dynamically loaded rules.

You write the rules, ruleguard checks whether they are satisfied.

ruleguard has some similarities with GitHub CodeQL, but only focuses on Go code queries.

Features:

  • Custom linting rules without re-compilation and Go plugins.
  • Diagnostics are written in a declarative way.
  • Quickfix actions support.
  • Powerful match filtering features, like expression type pattern matching.

ruleguard comes with rules.go file that can be used as a foundation to write your own rules file.

It can also be easily embedded into other static analyzers. go-critic can be used as an example.

Quick start

To install ruleguard binary under your $(go env GOPATH)/bin:

$ go get -v -u github.com/quasilyte/go-ruleguard/...

If $GOPATH/bin is under your system $PATH, ruleguard command should be available after that.

$ ruleguard -help
ruleguard: execute dynamic gogrep-based rules

Usage: ruleguard [-flag] [package]

Flags:
  -rules string
    	path to a rules.go file
  -e string
    	execute a single rule from a given string
  -fix
    	apply all suggested fixes
  -c int
    	display offending line with this many lines of context (default -1)
  -json
    	emit JSON output

Create a test example.rules.go file:

// +build ignore

package gorules

import "github.com/quasilyte/go-ruleguard/dsl/fluent"

func _(m fluent.Matcher) {
	m.Match(`$x

主要指標

概覽
名稱與所有者quasilyte/go-ruleguard
主編程語言Go
編程語言Go (語言數: 4)
平台Linux, Mac, Windows
許可證BSD 3-Clause "New" or "Revised" License
所有者活动
創建於2019-12-11 21:42:32
推送於2025-02-20 07:19:11
最后一次提交2025-02-20 08:19:11
發布數57
最新版本名稱v0.4.4 (發布於 )
第一版名稱v0.1.1 (發布於 )
用户参与
星數822
關注者數12
派生數42
提交數453
已啟用問題?
問題數164
打開的問題數59
拉請求數270
打開的拉請求數9
關閉的拉請求數41
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?