report

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate added in v0.10.0

type Aggregate map[string]any

An Aggregate is data collected by some rule while processing a file AST, to be used later by other rules needing a global context (i.e. broader than per-file) Rule authors are expected to collect the minimum needed data, to avoid performance problems while working with large Rego code repositories.

func (Aggregate) IndexKey added in v0.28.0

func (a Aggregate) IndexKey() string

IndexKey is the category/title of the rule that generated the aggregate. This key is generated in Rego during linting, this function replicates the functionality in Go for use in the cache when indexing aggregates.

func (Aggregate) SourceFile added in v0.28.0

func (a Aggregate) SourceFile() string

type Location

type Location struct {
	End    *Position `json:"end,omitempty"`
	Text   *string   `json:"text,omitempty"`
	File   string    `json:"file"`
	Column int       `json:"col"`
	Row    int       `json:"row"`
	Offset int       `json:"offset,omitempty"`
}

Location provides information on the location of a violation. End attribute added in v0.24.0 and ideally we'd have a Start attribute the same way. But as opposed to adding an optional End attribute, changing the structure of the existing struct would break all existing API clients.

func (Location) String

func (l Location) String() string

String shorthand form for a Location.

type Notice added in v0.12.0

type Notice struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Category    string `json:"category"`
	Level       string `json:"level"`
	Severity    string `json:"severity"`
}

Notice describes any notice found by Regal.

type Position added in v0.24.0

type Position struct {
	Row    int `json:"row"`
	Column int `json:"col"`
}

type ProfileEntry added in v0.10.0

type ProfileEntry struct {
	Location    string `json:"location"`
	TotalTimeNs int64  `json:"total_time_ns"`
	NumEval     int    `json:"num_eval"`
	NumRedo     int    `json:"num_redo"`
	NumGenExpr  int    `json:"num_gen_expr"`
}

ProfileEntry is a single entry of profiling information, keyed by location. This data may have been aggregated across multiple runs.

type RelatedResource

type RelatedResource struct {
	Description string `json:"description"`
	Reference   string `json:"ref"`
}

RelatedResource provides documentation on a violation.

type Report

type Report struct {
	// We don't have aggregates when publishing the final report (see JSONReporter), so omitempty is needed here
	// to avoid surfacing a null/empty field.
	Aggregates       map[string][]Aggregate         `json:"aggregates,omitempty"`
	Metrics          map[string]any                 `json:"metrics,omitempty"`
	AggregateProfile map[string]ProfileEntry        `json:"-"`
	IgnoreDirectives map[string]map[string][]string `json:"ignore_directives,omitempty"`
	Violations       []Violation                    `json:"violations"`
	Notices          []Notice                       `json:"notices,omitempty"`
	Profile          []ProfileEntry                 `json:"profile,omitempty"`
	Summary          Summary                        `json:"summary"`
}

Report aggregate of Violation as returned by a linter run.

func (*Report) AddProfileEntries added in v0.10.0

func (r *Report) AddProfileEntries(prof map[string]ProfileEntry)

func (*Report) AggregateProfileToSortedProfile added in v0.10.0

func (r *Report) AggregateProfileToSortedProfile(numResults int)

func (Report) ViolationsFileCount

func (r Report) ViolationsFileCount() map[string]int

ViolationsFileCount returns the number of files containing violations.

type Summary

type Summary struct {
	FilesScanned  int `json:"files_scanned"`
	FilesFailed   int `json:"files_failed"`
	RulesSkipped  int `json:"rules_skipped"`
	NumViolations int `json:"num_violations"`
}

type Violation

type Violation struct {
	Title            string            `json:"title"`
	Description      string            `json:"description"`
	Category         string            `json:"category"`
	Level            string            `json:"level"`
	RelatedResources []RelatedResource `json:"related_resources,omitempty"`
	Location         Location          `json:"location,omitempty"`
	IsAggregate      bool              `json:"-"`
}

Violation describes any violation found by Regal.

Jump to

Keyboard shortcuts

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