baseline

package
v0.17.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package baseline 冻结已有 lint 存量,使新债立刻变红。

为什么需要它:一个仓库第一次接入 appkit-lint 时通常带着上百条历史发现, 「全绿才能合并」等于逼团队在一次性大改和为规则开后门之间二选一。基线把 存量按条目登记下来,只放行登记过的诊断;新出现的诊断照旧失败。规则于是 对所有仓库立即生效,存量按正常节奏偿还。

条目键是 analyzer + 相对文件路径 + 消息 + 次数,**不含行号**:行号会被 无关改动整体推移,基线随之频繁失效,团队很快就会养成批量刷新的习惯, 棘轮形同虚设。同一条消息在一个文件里出现多次时按次数放行,超出的部分 仍然报错。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Baseline

type Baseline struct {
	// contains filtered or unexported fields
}

Baseline 是已加载的基线;零值表示空基线(一条也不放行)。

并发安全是硬要求:go/analysis 驱动会并行跑多个包,Suppressed 在多个 goroutine 里被调用;共享的可变额度表必须加锁,否则 race 检测直接报错, 且在无 race 构建下会静默漏扣或重复扣减。

func Load

func Load(path, root string) (*Baseline, error)

Load 读取基线文件。文件不存在时返回空基线而不是错误:尚未生成基线的 仓库应当表现为「全部报告」,而不是让工具启动失败。

func (*Baseline) Consumed

func (b *Baseline) Consumed() int

Consumed 返回已放行的诊断条数,供调用方提示还剩多少存量。

func (*Baseline) Suppressed

func (b *Baseline) Suppressed(analyzer string, pos token.Position, message string) bool

Suppressed 报告一次诊断是否已被基线覆盖。

同一诊断(analyzer+位置+消息)可能被驱动重复上报若干次(包的测试变体就是 这种情况)。判定必须**幂等**:重复上报返回同一结论,额度也只扣一次。否则 额度会按上报次数而非实际诊断条数消耗,测试变体多的包会在没有新增违规时 依然超标失败。

func (*Baseline) Total

func (b *Baseline) Total() int

Total 返回基线登记的条目总条数。

type Entry

type Entry struct {
	Analyzer string `json:"analyzer"`
	File     string `json:"file"`
	Message  string `json:"message"`
	Count    int    `json:"count"`
}

Entry 是一条被冻结的存量诊断。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL