popeye: github.com/derailed/popeye/internal/report Index | Files

package report

import "github.com/derailed/popeye/internal/report"

Index

Package Files

builder.go color.go delta_score.go emoji.go grade.go human.go junit.go logo.go prometheus.go tally.go writer.go

Constants

const (
    // DefaultFormat dumps sanitizer with color, emojis, the works.
    DefaultFormat = "standard"

    // JurassicFormat dumps sanitizer with 0 fancyness.
    JurassicFormat = "jurassic"

    // YAMLFormat dumps sanitizer as YAML.
    YAMLFormat = "yaml"

    // JSONFormat dumps sanitizer as JSON.
    JSONFormat = "json"

    // JunitFormat dumps sanitizer as JUnit report.
    JunitFormat = "junit"

    // PrometheusFormat pushes sanitizer as Prometheus metrics.
    PrometheusFormat = "prometheus"
)
const (
    // FontBold style
    FontBold = 1

    // Width denotes the maximum width of the sanitizer report.
    Width = 100
)

Variables

var  = []string{
    "o          .-'-.     ",
    " o     __| K    `\\  ",
    "  o   `-,-`--._   `\\",
    " []  .->'  a     `|-'",
    "  `=/ (__/_       /  ",
    "    \\_,    `    _)  ",
    "       `----;  |     ",
}

GraderLogo affords for replacing logo parts.

var  = []string{
    "K          .-'-.     ",
    " 8     __|      `\\  ",
    "  s   `-,-`--._   `\\",
    " []  .->'  a     `|-'",
    "  `=/ (__/_       /  ",
    "    \\_,    `    _)  ",
    "       `----;  |     ",
}

Logo popeye

var Popeye = []string{
    ` ___     ___ _____   _____ `,
    `| _ \___| _ \ __\ \ / / __|`,
    `|  _/ _ \  _/ _| \ V /| _| `,
    `|_| \___/_| |___| |_| |___|`,
}

Popeye title

func Colorize Uses

func Colorize(s string, c Color) string

Colorize a string based on given color.

func Colorizef Uses

func Colorizef(c Color, fmat string, args ...interface{}) string

Colorizef colorizes a formatted string.

func EmojiForLevel Uses

func EmojiForLevel(l issues.Level, jurassic bool) string

EmojiForLevel maps lint levels to emojis.

func Grade Uses

func Grade(score int) string

Grade returns a run report grade based on score.

func ResToTitle Uses

func ResToTitle(r string) string

ResToTitle converts a resource name to a title if any.

func Titleize Uses

func Titleize(r string, count int) string

Titleize returns a human readable resource name.

type Builder Uses

type Builder struct {
    Report Report `json:"popeye" yaml:"popeye"`
}

Builder represents sanitizer

func NewBuilder Uses

func NewBuilder() *Builder

NewBuilder returns a new sanitizer report.

func (*Builder) AddError Uses

func (b *Builder) AddError(err error)

AddError record an error associted with the report.

func (*Builder) AddSection Uses

func (b *Builder) AddSection(name string, o issues.Outcome, t *Tally)

AddSection adds a sanitizer section to the report.

func (*Builder) HasContent Uses

func (b *Builder) HasContent() bool

HasContent checks if we actually have anything to report.

func (*Builder) PrintClusterInfo Uses

func (b *Builder) PrintClusterInfo(s *Sanitizer, name string, metrics bool)

PrintClusterInfo displays cluster information.

func (*Builder) PrintHeader Uses

func (b *Builder) PrintHeader(s *Sanitizer)

PrintHeader prints report header to screen.

func (*Builder) PrintReport Uses

func (b *Builder) PrintReport(level issues.Level, s *Sanitizer)

PrintReport prints out sanitizer report to screen

func (*Builder) PrintSummary Uses

func (b *Builder) PrintSummary(s *Sanitizer)

PrintSummary print outs summary report to screen.

func (*Builder) ToJSON Uses

func (b *Builder) ToJSON() (string, error)

ToJSON dumps sanitizer to JSON.

func (*Builder) ToJunit Uses

func (b *Builder) ToJunit() (string, error)

ToJunit dumps sanitizer to JUnit.

func (*Builder) ToPrometheus Uses

func (b *Builder) ToPrometheus(address *string, cluster, namespace string) *push.Pusher

ToPrometheus returns prometheus pusher.

func (*Builder) ToYAML Uses

func (b *Builder) ToYAML() (string, error)

ToYAML dumps sanitizer to YAML.

type Color Uses

type Color int

Color tracks the output color.

const (
    ColorWhite     Color = 15
    ColorLighSlate Color = 75
    ColorGreen     Color = 82
    ColorCoolBlue  Color = 99
    ColorBlue      Color = 105
    ColorGreenPale Color = 114
    ColorAqua      Color = 122
    ColorDarkOlive Color = 155
    ColorYellow2   Color = 190
    ColorRed       Color = 196
    ColorOrangRed  Color = 202
    ColorOrange    Color = 208
    ColorOrangish  Color = 220
    ColorYellow    Color = 226
    ColorGray      Color = 250
)

Color ANSI palette (256!)

type DeltaScore Uses

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

DeltaScore tracks delta between 2 tally scores.

func NewDeltaScore Uses

func NewDeltaScore(level issues.Level, s1, s2 int, inverse bool) DeltaScore

NewDeltaScore returns a new delta score.

type Error Uses

type Error struct {
    XMLName xml.Name `xml:"error"`
    Message string   `xml:"message,attr"`
    Type    string   `xml:"type,attr"`
}

Error represents a test error..

type Failure Uses

type Failure struct {
    XMLName xml.Name `xml:"failure"`
    Message string   `xml:"message,attr"`
    Type    string   `xml:"type,attr"`
}

Failure represents a test failure.

type Issue Uses

type Issue interface {
    MaxSeverity(string) issues.Level
    Severity() issues.Level
    Description() string
    HasSubIssues() bool
    SubIssues() map[string][]Issue
}

Issue represents a sanitizer issues.

type Property Uses

type Property struct {
    Name  string `xml:"name,attr"`
    Value string `xml:"value,attr"`
}

Property represents key/value pair.

type Report Uses

type Report struct {
    Score    int       `json:"score" yaml:"score"`
    Grade    string    `json:"grade" yaml:"grade"`
    Sections []Section `json:"sanitizers,omitempty" yaml:"sanitizers,omitempty"`
    Errors   []error   `json:"errors,omitempty" yaml:"errors,omitempty"`
    // contains filtered or unexported fields
}

Report represents the output of a sanitization pass.

type Sanitizer Uses

type Sanitizer struct {
    io.Writer
    // contains filtered or unexported fields
}

Sanitizer represents a sanitizer report.

func NewSanitizer Uses

func NewSanitizer(w io.Writer, jurassic bool) *Sanitizer

NewSanitizer returns a new sanitizer report writer.

func (*Sanitizer) Badge Uses

func (s *Sanitizer) Badge(score int) []string

Badge returns a popeye grade.

func (*Sanitizer) Close Uses

func (s *Sanitizer) Close()

Close a report section.

func (*Sanitizer) Color Uses

func (s *Sanitizer) Color(msg string, c Color) string

Color or not this message by inject ansi colors.

func (*Sanitizer) Comment Uses

func (s *Sanitizer) Comment(msg string)

Comment writes a comment line.

func (*Sanitizer) Dump Uses

func (s *Sanitizer) Dump(l issues.Level, ii issues.Issues)

Dump all errors to output.

func (*Sanitizer) Error Uses

func (s *Sanitizer) Error(msg string, err error)

Error prints out error out.

func (*Sanitizer) Open Uses

func (s *Sanitizer) Open(msg string, t *Tally)

Open begins a new report section.

func (*Sanitizer) Print Uses

func (s *Sanitizer) Print(l issues.Level, indent int, msg string)

Print a colorized message.

type Section Uses

type Section struct {
    Title   string         `json:"sanitizer" yaml:"sanitizer"`
    Tally   *Tally         `json:"tally" yaml:"tally"`
    Outcome issues.Outcome `json:"issues,omitempty" yaml:"issues,omitempty"`
}

Section represents a sanitizer pass

type Tally Uses

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

Tally tracks lint section scores.

func NewTally Uses

func NewTally() *Tally

NewTally returns a new tally.

func (*Tally) Dump Uses

func (t *Tally) Dump(s *Sanitizer) string

Dump writes out tally and computes length

func (*Tally) IsValid Uses

func (t *Tally) IsValid() bool

IsValid checks if tally is valid.

func (*Tally) MarshalJSON Uses

func (t *Tally) MarshalJSON() ([]byte, error)

MarshalJSON renders a tally to JSON.

func (*Tally) MarshalYAML Uses

func (t *Tally) MarshalYAML() (interface{}, error)

MarshalYAML renders a tally to YAML.

func (*Tally) Rollup Uses

func (t *Tally) Rollup(o issues.Outcome) *Tally

Rollup tallies up the report scores.

func (*Tally) Score Uses

func (t *Tally) Score() int

Score returns the tally computed score.

func (*Tally) UnmarshalYAML Uses

func (t *Tally) UnmarshalYAML(f func(interface{}) error) error

UnmarshalYAML renders a tally to YAML.

type TestCase Uses

type TestCase struct {
    XMLName   xml.Name `xml:"testcase"`
    Classname string   `xml:"classname,attr"`
    Name      string   `xml:"name,attr"`
    Failures  []Failure
    Errors    []Error
}

TestCase represents a sing junit test.

type TestSuite Uses

type TestSuite struct {
    XMLName    xml.Name   `xml:"testsuite"`
    Name       string     `xml:"name,attr"`
    Tests      int        `xml:"tests,attr"`
    Failures   int        `xml:"failures,attr"`
    Errors     int        `xml:"errors,attr"`
    Properties []Property `xml:"properties>property,omitempty"`
    TestCases  []TestCase
}

TestSuite represents a collection of tests

type TestSuites Uses

type TestSuites struct {
    XMLName  xml.Name `xml:"testsuites"`
    Name     string   `xml:"name,attr"`
    Tests    int      `xml:"tests,attr"`
    Failures int      `xml:"failures,attr"`
    Errors   int      `xml:"errors,attr"`
    Suites   []TestSuite
}

TestSuites a collection of junit test suites.

Package report imports 14 packages (graph) and is imported by 2 packages. Updated 2019-11-21. Refresh now. Tools for package owners.