opa: github.com/open-policy-agent/opa/cover Index | Files

package cover

import "github.com/open-policy-agent/opa/cover"

Package cover reports coverage on modules.


Package Files


type Cover Uses

type Cover struct {
    // contains filtered or unexported fields

Cover computes and reports on coverage.

func New Uses

func New() *Cover

New returns a new Cover object.

func (*Cover) Config Uses

func (c *Cover) Config() topdown.TraceConfig

Config returns the standard Tracer configuration for the Cover tracer

func (*Cover) Enabled Uses

func (c *Cover) Enabled() bool

Enabled returns true if coverage is enabled.

func (*Cover) Report Uses

func (c *Cover) Report(modules map[string]*ast.Module) (report Report)

Report returns a coverage Report for the given modules.

func (*Cover) Trace Uses

func (c *Cover) Trace(event *topdown.Event)

Trace updates the coverage state. Deprecated: Use TraceEvent instead.

func (*Cover) TraceEvent Uses

func (c *Cover) TraceEvent(event topdown.Event)

TraceEvent updates the coverage state.

type CoverageThresholdError Uses

type CoverageThresholdError struct {
    Coverage  float64
    Threshold float64

CoverageThresholdError represents an error raised when the global code coverage percenta is lower than the specified threshold.

func (*CoverageThresholdError) Error Uses

func (e *CoverageThresholdError) Error() string

type FileReport Uses

type FileReport struct {
    Covered    []Range `json:"covered,omitempty"`
    NotCovered []Range `json:"not_covered,omitempty"`
    Coverage   float64 `json:"coverage,omitempty"`

FileReport represents a coverage report for a single file.

func (*FileReport) IsCovered Uses

func (fr *FileReport) IsCovered(row int) bool

IsCovered returns true if the row is marked as covered in the report.

func (*FileReport) IsNotCovered Uses

func (fr *FileReport) IsNotCovered(row int) bool

IsNotCovered returns true if the row is marked as NOT covered in the report. This is not the same as simply not being reported. For example, certain statements like imports are not included in the report.

type Position Uses

type Position struct {
    Row int `json:"row"`

Position represents a file location.

type PositionSlice Uses

type PositionSlice []Position

PositionSlice is a collection of position that can be sorted.

func (PositionSlice) Sort Uses

func (sl PositionSlice) Sort()

Sort sorts the slice by line number.

type Range Uses

type Range struct {
    Start Position `json:"start"`
    End   Position `json:"end"`

Range represents a range of positions in a file.

func (Range) In Uses

func (r Range) In(row int) bool

In returns true if the row is inside the range.

type Report Uses

type Report struct {
    Files    map[string]*FileReport `json:"files"`
    Coverage float64                `json:"coverage"`

Report represents a coverage report for a set of files.

func (Report) IsCovered Uses

func (r Report) IsCovered(file string, row int) bool

IsCovered returns true if the row in the given file is covered.

Package cover imports 5 packages (graph) and is imported by 9 packages. Updated 2020-06-08. Refresh now. Tools for package owners.