baseline

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadProfile

func ReadProfile(r io.Reader) (*Profile, *Stats, error)

ReadProfile reads a suppression profile from a provided reader.

func ReportHash

func ReportHash(scratchBuf *bytes.Buffer, fields HashFields) uint64

ReportHash computes the report signature hash for the baseline.

func WriteProfile

func WriteProfile(w io.Writer, p *Profile, stats *Stats) error

WriteProfile writes a given suppression profile to w.

Stats are included into the output as well.

Types

type FileProfile

type FileProfile struct {
	Filename string

	// Reports maps a warning hash to a suppression report info.
	Reports map[uint64]Report
}

FileProfile contains all reports suppressed for the associated file.

func (*FileProfile) Count

func (f *FileProfile) Count(hash uint64) int

Count returns the number of file reports that have the same hash.

How to interpret the return value: n=0 - warning is not suppressed n=1 - warning is suppressed n>1 - warning is suppressed and there are hash collisions

Hash collisions are handled by reports counting.

type HashFields

type HashFields struct {
	Filename  string
	PrevLine  []byte
	StartLine []byte
	NextLine  []byte
	CheckName string
	Message   string
	Scope     string
}

HashFields is a set of fields that are used during the report hash calculation.

type Profile

type Profile struct {
	LinterVersion string

	// CreatedAt is a Unix time that represents the moment at which
	// this profile was generated.
	CreatedAt int64

	Files map[string]FileProfile
}

Profile is a project-wide suppression profile (baseline file).

type Report

type Report struct {
	// Count is a number of reports that had the same hash.
	Count int

	Hash uint64
}

Report is a suppressed warning information.

type Stats

type Stats struct {
	// CountTotal is a total number of reports stored in the suppression profile.
	CountTotal int

	CountPerCheck map[string]int
}

Stats is an extra information that is saved to the suppression profile. It's not used by the linter itself, but it's useful for the other tools.

Jump to

Keyboard shortcuts

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