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?
已存档?
是复刻?
已锁定?
是镜像?
是私有?