printer

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// OutFormatText is a text-based output format, best for CLIs
	OutFormatText = "text"
	// OutFormatSimple is a simplified output format, which can be used with something like https://github.com/reviewdog/reviewdog
	OutFormatSimple = "simple"
	// OutFormatGitHubActions is an output format supported by GitHub Actions annotations
	// https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message
	OutFormatGitHubActions = "github-actions"

	// OutFormatJSON outputs in json
	OutFormatJSON = "json"

	// OutFormatSonarQube is an output format supported by SonarQube
	// https://docs.sonarqube.org/latest/analysis/generic-issue/
	OutFormatSonarQube = "sonarqube"

	// OutFormatCheckstyle outputs in checkstyle format.
	// https://github.com/checkstyle/checkstyle
	OutFormatCheckstyle = "checkstyle"
)

Variables

OutFormats are all the available output formats. The first one should be the default

View Source
var OutFormatsString = strings.Join(OutFormats, ",")

OutFormatsString is all OutFormats, as a comma-separated string

Functions

This section is empty.

Types

type Checkstyle added in v0.19.0

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

Checkstyle is a Checkstyle printer meant for use by a Checkstyle annotation

func NewCheckstyle added in v0.19.0

func NewCheckstyle(w io.Writer) *Checkstyle

NewCheckstyle returns a new Checkstyle printer

func (*Checkstyle) End added in v0.19.0

func (p *Checkstyle) End()

func (*Checkstyle) Print added in v0.19.0

func (p *Checkstyle) Print(fs *result.FileResults) error

Print prints in the format for Checkstyle. https://github.com/checkstyle/checkstyle

func (*Checkstyle) PrintSuccessExitMessage added in v0.19.0

func (p *Checkstyle) PrintSuccessExitMessage() bool

func (*Checkstyle) Start added in v0.19.0

func (p *Checkstyle) Start()

type Error added in v0.19.0

type Error struct {
	XMLName  xml.Name `xml:"error"`
	Column   int      `xml:"column,attr"`
	Line     int      `xml:"line,attr"`
	Message  string   `xml:"message,attr"`
	Severity string   `xml:"severity,attr"`
	Source   string   `xml:"source,attr"`
}

type File added in v0.19.0

type File struct {
	XMLName xml.Name `xml:"file"`
	Name    string   `xml:"name,attr"`
	Errors  []Error  `xml:"error"`
}

type GitHubActions

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

GitHubActions is a GitHubActions printer meant for use by a GitHub Action annotation

func NewGitHubActions

func NewGitHubActions(w io.Writer) *GitHubActions

NewGitHubActions returns a new GitHubActions printer

func (*GitHubActions) End added in v0.13.0

func (p *GitHubActions) End()

func (*GitHubActions) PrintSuccessExitMessage added in v0.13.0

func (p *GitHubActions) PrintSuccessExitMessage() bool

func (*GitHubActions) Start added in v0.13.0

func (p *GitHubActions) Start()

type Issue added in v0.13.0

type Issue struct {
	EngineID        string   `json:"engineId"`
	RuleID          string   `json:"ruleId"`
	PrimaryLocation Location `json:"primaryLocation"`
	Type            string   `json:"type"`
	Severity        string   `json:"severity"`
}

type JSON added in v0.2.0

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

JSON is a JSON printer meant for a machine to read

func NewJSON added in v0.2.0

func NewJSON(w io.Writer) *JSON

NewJSON returns a new JSON printer

func (*JSON) End added in v0.13.0

func (p *JSON) End()

func (*JSON) Print added in v0.2.0

func (p *JSON) Print(fs *result.FileResults) error

Print prints in FileResults as json NOTE: The JSON printer will bring each line result as a JSON string. It will not be presented as an array of FileResults. You will neeed to Split by new line to parse the full output

func (*JSON) PrintSuccessExitMessage added in v0.13.0

func (p *JSON) PrintSuccessExitMessage() bool

func (*JSON) Start added in v0.13.0

func (p *JSON) Start()

type Location added in v0.13.0

type Location struct {
	Message   string    `json:"message"`
	FilePath  string    `json:"filePath"`
	TextRange TextRange `json:"textRange"`
}

type Printer

type Printer interface {
	Print(*result.FileResults) error
	Start()
	End()
	PrintSuccessExitMessage() bool
}

Printer is an interface for printing FileResults

func NewPrinter added in v0.1.1

func NewPrinter(f string, w io.Writer) (Printer, error)

NewPrinter returns a valid new Printer from a string, or an error if the printer is invalid

type Simple

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

Simple is a simple printer meant for a machine to read

func NewSimple

func NewSimple(w io.Writer) *Simple

NewSimple returns a new simple printer

func (*Simple) End added in v0.13.0

func (p *Simple) End()

func (*Simple) Print

func (p *Simple) Print(fs *result.FileResults) error

Print prints in the format 'filename:line:column: message' based on golint's output: https://github.com/golang/lint/blob/738671d3881b9731cc63024d5d88cf28db875626/golint/golint.go#L121

func (*Simple) PrintSuccessExitMessage added in v0.13.0

func (p *Simple) PrintSuccessExitMessage() bool

func (*Simple) Start added in v0.13.0

func (p *Simple) Start()

type SonarQube added in v0.13.0

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

SonarQube is a JSON printer meant for import into SonarQube

func NewSonarQube added in v0.13.0

func NewSonarQube(w io.Writer) *SonarQube

NewSonarQube returns a new SonarQube JSON printer

func (*SonarQube) End added in v0.13.0

func (p *SonarQube) End()

func (*SonarQube) Print added in v0.13.0

func (p *SonarQube) Print(fs *result.FileResults) error

Print outputs lines in FileResults as sonarqube json format. NOTE: Start() must be called before printing results and End() after printing is complete in order to form a valid JSON structure for sonarqube to import.

func (*SonarQube) PrintSuccessExitMessage added in v0.13.0

func (p *SonarQube) PrintSuccessExitMessage() bool

func (*SonarQube) Start added in v0.13.0

func (p *SonarQube) Start()

type Text

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

Text is a text printer meant for humans to read

func NewText

func NewText(w io.Writer, disableColor bool) *Text

NewText returns a text Printer with color optionally disabled

func (*Text) End added in v0.13.0

func (t *Text) End()

func (*Text) Print

func (t *Text) Print(fs *result.FileResults) error

Print prints the file results

func (*Text) PrintSuccessExitMessage added in v0.13.0

func (t *Text) PrintSuccessExitMessage() bool

func (*Text) Start added in v0.13.0

func (t *Text) Start()

type TextRange added in v0.13.0

type TextRange struct {
	StartLine   int `json:"startLine"`
	StartColumn int `json:"startColumn"`
	EndColumn   int `json:"endColumn"`
}

Jump to

Keyboard shortcuts

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