printer

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 11 Imported by: 0

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

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

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

func NewCheckstyle

func NewCheckstyle(w io.Writer) *Checkstyle

NewGitHubActions returns a new GitHubActions printer

func (*Checkstyle) End

func (p *Checkstyle) End()

func (*Checkstyle) PrintSuccessExitMessage

func (p *Checkstyle) PrintSuccessExitMessage() bool

func (*Checkstyle) Start

func (p *Checkstyle) Start()

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

func (p *GitHubActions) End()

func (*GitHubActions) PrintSuccessExitMessage

func (p *GitHubActions) PrintSuccessExitMessage() bool

func (*GitHubActions) Start

func (p *GitHubActions) Start()

type Issue

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

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

JSON is a JSON printer meant for a machine to read

func NewJSON

func NewJSON(w io.Writer) *JSON

NewJSON returns a new JSON printer

func (*JSON) End

func (p *JSON) End()

func (*JSON) Print

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

func (p *JSON) PrintSuccessExitMessage() bool

func (*JSON) Start

func (p *JSON) Start()

type Location

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

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

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

func (p *Simple) PrintSuccessExitMessage() bool

func (*Simple) Start

func (p *Simple) Start()

type SonarQube

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

SonarQube is a JSON printer meant for import into SonarQube

func NewSonarQube

func NewSonarQube(w io.Writer) *SonarQube

NewSonarQube returns a new SonarQube JSON printer

func (*SonarQube) End

func (p *SonarQube) End()

func (*SonarQube) Print

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

func (p *SonarQube) PrintSuccessExitMessage() bool

func (*SonarQube) Start

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

func (t *Text) End()

func (*Text) Print

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

Print prints the file results

func (*Text) PrintSuccessExitMessage

func (t *Text) PrintSuccessExitMessage() bool

func (*Text) Start

func (t *Text) Start()

type TextRange

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